Thread overview
opIndexAssign Question
Aug 20, 2005
AJG
Aug 21, 2005
Ben Hinkle
Aug 21, 2005
AJG
August 20, 2005
Hi,

I believe right now, if you do:

# Foo[""] = 42;
It is equivalent to:
# Foo.opIndexAssign(42, "");

If you do:

# Foo[""] = (42, 13);
It's equivalent to:
# Foo.opIndexAssign((42, 13), "");

And finally, if you do:

# Foo[""] = 42, 13;
It is equivalent to:
# (Foo[""] = 42), 13;
meaning:
# Foo.opIndexAssign(42, ""), 13;

Is that all correct?

------------

If so, is there a way to get

# Foo[""] = 42, 13;
to be equal to:
# Foo.opIndexAssign(42, 13, "");
instead?
or maybe:
# Foo.opIndexAssign([42, 13], "");
Meaning a typesafe variadic array?

Thanks,
--AJG.




August 21, 2005
"AJG" <AJG_member@pathlink.com> wrote in message news:de8a35$1tte$1@digitaldaemon.com...
> Hi,
>
> I believe right now, if you do:
>
> # Foo[""] = 42;
> It is equivalent to:
> # Foo.opIndexAssign(42, "");
>
> If you do:
>
> # Foo[""] = (42, 13);
> It's equivalent to:
> # Foo.opIndexAssign((42, 13), "");
>
> And finally, if you do:
>
> # Foo[""] = 42, 13;
> It is equivalent to:
> # (Foo[""] = 42), 13;
> meaning:
> # Foo.opIndexAssign(42, ""), 13;
>
> Is that all correct?

It should be, yeah.

> ------------
>
> If so, is there a way to get
>
> # Foo[""] = 42, 13;
> to be equal to:
> # Foo.opIndexAssign(42, 13, "");
> instead?
> or maybe:
> # Foo.opIndexAssign([42, 13], "");
> Meaning a typesafe variadic array?


not without changing the language. You might want to try a method instead of using opIndexAssign. Something like Foo.insert(char[] key, int[] data...)

>
> Thanks,
> --AJG.


August 21, 2005
Hi,

>> If so, is there a way to get
>>
>> # Foo[""] = 42, 13;
>> to be equal to:
>> # Foo.opIndexAssign(42, 13, "");
>> instead?
>> or maybe:
>> # Foo.opIndexAssign([42, 13], "");
>> Meaning a typesafe variadic array?

>not without changing the language. You might want to try a method instead of using opIndexAssign. Something like Foo.insert(char[] key, int[] data...)

Ah, ok. Speaking of which, how come the variadic part of the function signature can't come ahead of the fixed part?

For example:

# void Foo(int[] a..., string b);

# Foo(1, 2, 3, "hello"); // OK.
# Foo("hello");          // OK.
# Foo(1, 2, 3);          // Error.
# Foo();                 // Error.
# Foo("hello", 1, 2, 3); // Error.
# Foo("hello", "world"); // Error.
# // etc...

Thanks,
--AJG.