Consider this oft-repeated pattern:

 dim items() as string = Array(...)
 for each item as string in items()
    ...
 next

Why is "as string" necessary in the "for" statement? I'd rather just say:

 dim items() as string = Array(...)
 for each item in items()
    ...
 next

The loop would be independent of type, making it less cluttered, and
more generic & reusable. Furthermore, if Array is replaced by a
function whose type is known, I'd like to say:

 Function ImportantItems() as string
   ...
 End Function

 dim items() = ImportantItems
 for each item in items
   ...
 next

If this is enough for the compiler:

 const i = 3

then why aren't these?

 dim i = 3 // default to Integer (not double, int32, etc.)

 for i = 1 to 10
   ...
 next

I haven't thought this through in terms of Interfaces and return type
covariance (and maybe other stuff), but it seems that "as <type>"
could be optional in quite a bit of my code. My fingers certainly
think it is; the compiler routinely badgers me for leaving it out.

Comments from the language mavens? Has the world already tried &
rejected this experiement?

lj
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to