View mode: basic / threaded / horizontal-split · Log in · Help
July 17, 2005
Re: structs and protection
Jarrett Billingsley wrote:
> Foo f={1,2,3};
> 
> Is obvious, something like
> 
> fork({1,2,3});
> 
> Isn't.  We were thinking something like
> 
> fork(cast(Foo){1,2,3});
> 
> But that's kind of ugly and might present parsing problems.

That's pretty much exactly it (although if the only definition of fork() available expects 
a Foo, then its pretty easy to deduce... but the argument-on-topic stays valid).  And why 
am I responding?  To take one more stab at my preferred solution-syntax, of course.  :)

# fork(new Foo {1,2,3});

Ta-da.  Could work well with arrays too.

# func(new int[] [1,2,3]);

Although for arrays there's a simple template function one can use, but that doesn't 
really solve anything.  And I still want to see AA literals, something like:

# int[char[]] map = new int[char[]] [
#   `foo`  : 1  ,
#   `bar`  : 2  ,
#   `bob`  : 5  ,
#   `eris` : 42
# ];

The only potential issue with using 'new' is that it is usually understood to represent a 
heap allocation.  So maybe it needs a companion keyword or some other method to do a stack 
allocation as one normally would for structs and such.

-- Chris Sauls
Next ›   Last »
1 2
Top | Discussion index | About this forum | D home