January NWCPP Presentation

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Sat Jan 27 05:30:00 PST 2007


Bill Baxter wrote:
> Walter Bright wrote:
>> Kyle Furlong wrote:
>>> How did it go? :-)
>>
>> I've been told it went over well. The video is supposed to go up on 
>> google video at some point.
> 
> Slides from the talk are up now.
> 
> http://www.nwcpp.org/Meetings/2007/01.html

 From the section on expression tuples:
"""
It can be used to create an array literal:

alias Tuple!(3, 7, 6) AT;

...
int[] a = [AT];		// same as [3,7,6]
"""

I was surprised to read this, as I tried that very thing just yesterday 
and it didn't work. I have now investigated further. My findings:
-----
import std.stdio;

alias Tuple!(1,2,3) AT;

void main() {
     int[] foo_dyn_local = [AT];     // works
     int[3] foo_static_local = [AT]; // works

     writefln(foo_dyn_local);
     writefln(foo_static_local);
//    writefln(foo_dyn_global);
//    writefln(foo_static_global);


}

// Error: cannot implicitly convert expression (tuple1,2,3)
// of type (int, int, int) to int
//int[] foo_dyn_global = [AT];

// Error: cannot implicitly convert expression (tuple1,2,3)
// of type (int, int, int) to int
//int[3] foo_static_global = [AT];
-----

Why does this only work at function scope?



More information about the Digitalmars-d mailing list