Ian Piumarta <[EMAIL PROTECTED]> writes:
> On Jun 20, 2007, at 8:20 AM, Michael FIG wrote:
>
>> I could really use variadic methods. I seem to recall they were
>> being
>> discussed earlier, but I can't find an archive.
>
> These haven't worked for a while. The Parser does still recognise
> '...' at the end of a method pattern but the Encoder doesn't
> implement the method required to deal with it. If you can think of a
> nice syntax to represent 'the next unnamed variadic argument' (i.e.,
> the thing that would be translated as 'va_arg(ap, oop)') I'd happily
> reinstate it.
How about simply using "..." itself as token for the next argument?
Object sum ...
[
| sum next |
sum := 0.
[(next := ...) == nil] whileFalse: [sum := sum + next].
^sum
]
[
Object sum : 1 : 2 : 3 : nil.
]
The ugly thing about this is that it still has C semantics, you need
some manual mechanism to determine how many times to invoke "...".
Guess that can't be helped at this level?
Although, if we have C semantics anyway we could write
[... == nil] whileFalse: [sum := sum + ...++]
with "..." meaning the current argument and "...++" the current
argument, but advance to next. Okay, that was not serious ;)
Also, it's not simple to pass the variadic arguments to another
variadic method. That could be helped by making "..." actually refer
to an array of arguments. Then one could use regular iteration over
the array to access arguments.
- Bert -
_______________________________________________
fonc mailing list
[email protected]
http://vpri.org/mailman/listinfo/fonc