Hi,
Isn’t * an array to values converter?
(like in method(1, *[2, 3, 4]))?I don’t think so, even with your proposal. If * (splat operator) is
an array to values converter,def func1(a,b)
[a,b]
end
func1(1, *[2, 3, 4])should give [1,2], unless values work like LIST in Perl.
I tried it. It raises a wrong number of argument error (4 for 2).
However:
def func1(a,b,*rest)
[a,b]
end
func1(1, *[2, 3, 4])
do give [1,2]
- Comparing multiple values
- Unify operator
I have to confess I couldn’t understand those two proposals, how they
behave, and how they are useful.The idea of comparing multiple values would be a kind of
syntactic sugar.
Instead of writing
x == 1 && y == 2
you could write
x, y == 1, 2
(which looks much clearer in my eyes).Not for my eyes. YMMV.
Not obvious to me either. If feel like I would rather write
if [x, y] == [1, 2] then
OTOH, x, y == 1, 2 may help avoid building 2 Array objects and
speed things up (an optimizing compiler could do that too).
I don’t feel right to mix comparison operands x, 1, and y, 2.
matz.
I agree.
I feel like extending the syntax is worthwhile if the added
benefit is really significant.
Rather than allowing x, y == 1, 2, I would prefer a more
general x, y =~= 1, 2 whose semantic is richer due to the
fact that it may end up assigning either x, y or both if
they don’t exist already (or if they were unbound/freed).
Yours,
Jean-Hugues
···
At 08:53 28/04/2004 +0900, you wrote:
In message “Re: Semantics of Multiple Values (updated RCR)” > on 04/04/28, Kristof Bastiaensen kristof@vleeuwen.org writes:
Web: http://hdl.handle.net/1030.37/1.1
Phone: +33 (0) 4 92 27 74 17