Calling foo and bar with the same arguments should yield the same output.
component q
export Executable
bar(x:Any...) = do println i, i <- x end
foo(x:Any...) = bar(x)
run(args:String...) = do
println "foo"
foo(1,2)
println "bar"
bar(1,2)
end
end
But instead it produces this output:
foo
[0#2](immutable) = [ 1 2 ]
bar
1
2
A similar thing in Java works:
public class x{
public static void bar( String... f ){
for ( String z : f ){
System.out.println( z );
}
}
public static void foo( String... f ){
bar(f);
}
public static void main( String... args ){
System.out.println( "foo" );
foo( "1", "2", "3" );
System.out.println( "bar" );
bar( "1", "2", "3" );
}
}
Output:
foo
1
2
3
bar
1
2
3
Is it right for the interpreter to wrap varargs with an array?