History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: BOO-614
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Rodrigo B. de Oliveira
Reporter: Rodrigo B. de Oliveira
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Boo

type array literal

Created: 19/Nov/05 01:19 PM   Updated: 22/Nov/05 02:27 PM
Component/s: Compiler
Affects Version/s: None
Fix Version/s: 0.7.5

Time Tracking:
Not Specified

Testcase included: yes


 Description  « Hide
"""
System.Int32[]
1 2 3
3
System.String[]

2
System.Int32[]

0
System.String[]
foo
1
"""
def dump(a):
print a.GetType()
print join(a)
print len(a)

a1 = (of int: 1L, 2, 3.1)
dump(a1)

a2 = (of string: null, null)
dump(a2)

a3 = (of int:,)
dump(a3)

a4 = (of string: "foo")
dump(a4)



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Christopher Osborn - 21/Nov/05 05:08 AM
This is a fantastic addition, but are the colon and comma really necessary in example 3? In my mind that would make a two-dimensional array.

Is:
a3 = (of int)
not feasible?


Rodrigo B. de Oliveira - 21/Nov/05 05:41 AM
There are two main reasons for that:

1) the type declaration is a decoration to an array literal, the empty array literal is: (,)
2) array types will be changed from (type) to (of type), this way, standalone array types will no longer need typeof around them in expression, example:

arrayOfInt = (of int)
print arrayOfInt.GetType() # System.Type
print arrayOfInt # System.Int32[]

l = [(1, 2), (3, 4)]

a1 = l.ToArray((of int)) # today
a2 = l.ToArray[of (of int)]() # future with generics


Christopher Osborn - 21/Nov/05 08:41 AM
OK. How would one do a multi-dimensional array in this new hotness, then? Or is "array" out(ish), but "matrix" still in?

Bill Wood - 22/Nov/05 02:27 PM
Why not this syntax ("of int:" looks ugly to me)
a1 = (1L, 2, 3.1) as int