Hi,
Juerd wrote:
> Ingo Blechschmidt skribis 2005-12-25 17:37 (+0100):
>> I disagree about binding only being a language thing:
>
> I fail to see how your example code illustrates your disagreement.
>
>> return 42
>> if (my $short := $long_param
Hi,
Juerd wrote:
> The next thing I thought was: hey, argument *passing* is actually
> *binding* to variables in the sub, so why not use the := operator?
> That works very well, because binding as an expression makes no sense
> anyway, it being a language thing. And luckily, named arguments are
>
Hi,
Andrew Savige wrote:
> In Pugs, you can process a simple list of lists like this:
>
> my @lol = ( [ '1a', '1b' ], [ '2a', '2b' ], [ '3a', '3b' ] );
> for @lol -> $t { say "1st='$t[0]' 2nd='$t[1]'" }
>
> Yet the $t[0] and $t[1] look untidy to me, so I'd prefer to specify
> that the for closur
Hi,
my ($a, $b, $c) = ;
my $also_a := ($a,$b,$c)[0];
$also_a eq "a"; # correct?
$also_a = "A"; # does not die?
$a eq "A"; # true?
my $also_b = "b";
($a,$b,$c)[1] := $also_b;
$b eq "b"; # true?
$b = "B";# does not die?
$also_b eq
Hi,
Luke Palmer wrote:
> On 11/21/05, Ingo Blechschmidt <[EMAIL PROTECTED]> wrote:
>> Hm. How is (*@;AoA) different from (Array [EMAIL PROTECTED]) then? (Assuming
>> that
>> foo(@a; @b) desugars to foo([EMAIL PROTECTED], [EMAIL PROTECTED]).)
>
> Well, it
Hi,
Larry Wall wrote:
> On Sun, Nov 20, 2005 at 08:51:03PM +0100, Ingo Blechschmidt wrote:
> : according to the new S03, till is the new name for the flipflop
> : operator.
>
> Presuming we can make it work out as an infix macro.
Ah, it's a macro. This clarifies things.
Hi,
Rob Kinyon wrote:
> On 11/20/05, Ingo Blechschmidt <[EMAIL PROTECTED]> wrote:
>> Yep. Also note that "for" is not a special magical construct in Perl
>> 6, it's a simple subroutine (&statement_control:, with the
>> signature ([EMAIL PROTECTED
Hi,
Luke Palmer wrote:
> On 11/20/05, Ingo Blechschmidt <[EMAIL PROTECTED]> wrote:
>> sub foo (*@;AoA) { @;AoA }
>>
>> my @array1 = ;
>> my @array2 = ;
>>
>> my @AoA = foo @array1, @array2;
>> say [EMAIL PROTECTED]; #
Hi,
quoting r6624 of S06 [1]:
> Some functions take multiple Lists that they wish not to be flattened
> into one list. For instance, C wants to iterate several lists
> in parallel, while array and hash subscripts want to process
> multidimensional slices. The set of underlying argument list (List
Hi,
according to the new S03, till is the new name for the flipflop
operator.
Do the flipflop operators of subroutines maintain own
per-invocation-of-the-sub states? I.e.:
sub foo (&x) { x() till 0 }
foo { 0 }; # evaluates to a false value, of course
foo { 1 }; # evaluates to a t
Hi,
Juerd wrote:
> Ingo Blechschmidt skribis 2005-11-20 16:44 (+0100):
>> Where is the difference (for the user) between a subroutine which
>> returns an appropriate proxy object and an array?
>
> The big difference between pure arrays and referenced arrays, for the
> u
Hi,
Juerd wrote:
> Will Perl 6 support mutable for-reverse?
I'd like it! :)
> Some possible answers that I could think of:
>
> (a) Yes, but as a special case
> (b) Yes, because reverse returns lvalue aliases
> (c) No
>
> But there's another one, that I didn't immediately think of:
>
> (d) Yes
Hi,
Larry Wall wrote:
> On Sun, Nov 06, 2005 at 03:10:40PM +0100, Ingo Blechschmidt wrote:
[ => should not automatically bind its .value to the RHS ]
> I think binding directly to .key or .value is different from what =>
> does. So after
>
> $pair = $key => $va
Hi,
my ($key, $value) = ;
my $pair = ($key => $value);
$pair.key = "new";
# Should this fail ("cannot modify a constant")?
# Should this update $pair.key, but leave $key untouched?
# Should this update $pair.key, implicitly updating $key as well?
$pair.value
Hi,
TSa wrote:
> Ingo Blechschmidt wrote:
>> Exactly. I'd like to add that, under the proposal, you always know
>> what things are passed how, only by looking for a "*".
>>
>> foo $var;# always positionally, even if $var isa Pair
>> f
Hi,
Stuart Cook wrote:
> On 11/10/05, Austin Hastings <[EMAIL PROTECTED]> wrote:
>> A rule that says
>> "splatting
>> a list coerces all pairs into named args" works just fine. The
>> corresponding rule, "acc
Hi,
Juerd wrote:
> Ingo Blechschmidt skribis 2005-10-10 20:08 (+0200):
>> Named arguments can -- under the proposal -- only ever exist in
>> calls.
>
> Which leaves us with no basic datastructure that can hold both
> positional and named arguments. This is a problem becau
Hi,
Juerd wrote:
> Ingo Blechschmidt skribis 2005-10-10 19:59 (+0200):
>> my @args = ( (a => 1), b => 2 ); # is sugar for
>> my @args = ( (a => 1), (b => 2) );
>
> Please, no. Please let the pair constructor be =>, not (=>). There is
> really no
Hi,
Juerd wrote:
> Ingo Blechschmidt skribis 2005-10-10 19:36 (+0200):
>> my @array = (42, "hi", (a => 23));
>
> It is worth pointing out that the inner parens here are merely for
> grouping: this information is lost afterwards, hence this:
>
>&g
Hi,
Dave Whipp wrote:
> Austin Hastings wrote:
>> How about "perl should DWIM"? In this case, I'm with Juerd: splat
>> should pretend that my array is a series of args.
>>
>> So if I say:
>>
>> foo [EMAIL PROTECTED];
>>
>> or if I say:
>>
>> foo([EMAIL PROTECTED]);
>>
>> I still mean the same
Hi,
Mark Reed wrote:
> On 2005-10-10 13:36, "Ingo Blechschmidt" <[EMAIL PROTECTED]> wrote:
>> Under the proposal, a Pair object doesn't have any special
>> magic
>
> Right. So under this proposal, the "key => value" syntax is
> ove
Hi,
Austin Hastings wrote:
> How about "perl should DWIM"? In this case, I'm with Juerd: splat
> should pretend that my array is a series of args.
Yep.
> So if I say:
>
> foo [EMAIL PROTECTED];
>
> or if I say:
>
> foo([EMAIL PROTECTED]);
>
> I still mean the same thing: shuck the array and
Hi,
Uri Guttman wrote:
>>>>>> "IB" == Ingo Blechschmidt <[EMAIL PROTECTED]> writes:
> IB> * "(key => $value)" (with the parens) is always a positionally
> passed
> IB> Pair object. "key => $value" (witho
Hi,
while fixing bugs for the imminent Pugs 6.2.10 release, we ran into
several issues with magical pairs (pairs which unexpectedly participate
in named binding) again. Based on Luke's "Demagicalizing pairs" thread
[1], #perl6 refined the exact semantics [2].
The proposed changes are:
* "(key =>
Hi,
TSa wrote:
> Yuval Kogman wrote:
>> On Wed, Sep 28, 2005 at 11:46:37 -0500, Adam D. Lopresto wrote:
>>>thinking for a while. In short, I propose that "use fatal" be on by
>>>default, and that "err" be turned into syntactic sugar for a very
>>>small try/CATCH block.
>>
>> I like it a lot. It
Hi,
Juerd wrote:
> Ingo Blechschmidt skribis 2005-09-21 17:24 (+0200):
>> multi prefix:<\> (Item $item) {...}
>> multi prefix:<\> (@array) {...}
>> multi prefix:<\> (%hash) {...}
>
> I keep forgetting. What's the rule for d
Hi,
Matt Fowles wrote:
> On 9/21/05, Ingo Blechschmidt <[EMAIL PROTECTED]> wrote:
>> foo(1,2,3); # &infix:<,> *not* called
>> foo (1,2,3); # same as
>> foo( (1,2,3) ); # &infix:<,> called
>
> Do you mean this to read
Hi,
(sorry for the long delay.)
Juerd convolution.nl> writes:
> Ingo Blechschmidt skribis 2005-09-19 14:21 (+):
> > \(1,2,3);# Reference to a list promoted to an array (!)
> > \(((1,2,3)));# same
>
> Except that it has to be a reference to a
Hi,
quick questions:
my $pair = (a => 42);
say ~$pair; # "a\t42"? "a\t42\n"? "a 42"?
say +$pair; # 0 (pairs aren't numbers)?
# 42?
# 0 ("a" is not a number)?
# 0 (~$pair can't be used as a number)?
say ?$pair; # true (because 4
Hi,
TSa orthogon.com> writes:
> Ingo Blechschmidt wrote:
> > [EMAIL PROTECTED];# Ref to array
> >
> > \(@array); # List of refs to @array's elements, i.e. same as
> > map { \$_ } @array;
> > # Weird (violating the
Hi,
Larry Wall wrote:
> The only questions in my mind are whether Perl 5's \($a,$b) is
> what people expect (it's arguably counterintuitive to newbies),
> and whether there's some other construct that would more naturally
> construct a list of references. It's not just \« though, since it
> has t
Hi,
# Should this work?
say (a => 1, b => 2); # 2 or error?
# Similarily:
my @array = (a => 1, b => 2);
say @array;
my $arrayref = [ a => 1, b => 2 ];
say $arrayref;
FWIW, I think accessing arrays and arrayrefs by key should probably not
work, but I'm unsure on (...
Hi,
Larry Wall wrote:
> On Fri, Sep 09, 2005 at 04:40:11PM +0200, Juerd wrote:
> : Ingo Blechschmidt skribis 2005-09-09 15:12 (+0200):
> : > I agree that the comma operator creates an anonymous array, but I
> : > do not agree that it behaves as if it has [] around it.
> :
Hi,
Juerd wrote:
> Ingo Blechschmidt skribis 2005-09-09 15:12 (+0200):
>> I agree that the comma operator creates an anonymous array, but I do
>> not agree that it behaves as if it has [] around it.
>>
>> Creating an anonymous array does not require creating new contai
Hi,
Juerd wrote:
> Ingo Blechschmidt skribis 2005-09-09 11:59 (+):
>> > > > \(@array,) is [ @array ], NOT map { \$_ } @array
>> > > I'm not sure of the []s, remember &postcirumfix:<[ ]> creates
>> > > *new* containers:
>
Hi,
Juerd convolution.nl> writes:
> Ingo Blechschmidt skribis 2005-09-06 21:24 (+0200):
> > > \(@array,) is [ @array ], NOT map { \$_ } @array
> > I'm not sure of the []s, remember &postcirumfix:<[ ]> creates *new*
> > containers:
>
> T
Hi,
Juerd wrote:
> Ingo Blechschmidt skribis 2005-09-06 19:46 (+0200):
>> If \(...) still constructs a list of references, are the following
>> assumptions correct?
>
> IIRC, the RHS of \ is in scalar context, and the comma in scalar
> context (the parens are just for
Hi,
# Perl 5
my @array_of_references = \($foo, $bar, $baz);
print [EMAIL PROTECTED];# prints 3
print ${ $array_of_references[1] }; # prints $bar
# Perl 6
my @array = \($foo, $bar, $baz);
say [EMAIL PROTECTED];
# 3 (like Perl 5)?
# Or 1, making \(...) s
Hi,
quick questions:
constant pi = 3; # works
# Is &pi package- or lexically-scoped?
our constant pi = 3; # legal?
my constant pi = 3; # legal?
This is consistent with "sub foo", "our sub foo", and "my sub foo",
which are all allowed.
--Ingo
--
Hi,
Larry Wall wrote:
> On Fri, Sep 02, 2005 at 05:56:39PM +0200, Ingo Blechschmidt wrote:
> : multi foo ($a) {...}
> : multi foo ($a, $b) {...}
> :
> : say &foo.arity;
> : # die? warn and return 0? warn and return undef? return 1|2?
>
&
Hi,
multi foo ($a) {...}
multi foo ($a, $b) {...}
say &foo.arity;
# die? warn and return 0? warn and return undef? return 1|2?
--Ingo
--
Linux, the choice of a GNU | There are no answers, only
generation on a dual AMD | cross-references.
Athlon!|
Hi,
my $arrayref = ;
for @$arrayref {...};# loop body executed three times, of course
for ($arrayref,) {...}; # loop body executed only one time
for ($arrayref) {...}; # loop body executed one or three times?
for $arrayref {...}; # loop body executed one or three t
Hi,
@array = $scalar;# really means
@array = ($scalar,); # same as
@array = (); @array[0] = $scalar;
# Correct?
@array = $arrayref; # really means
@array = ($arrayref,); # same as
@array = ();
Hi,
Yuval Kogman wrote:
> On Sat, Aug 27, 2005 at 19:16:55 +0200, Ingo Blechschmidt wrote:
>
>>my ($head, [EMAIL PROTECTED]) := foo();
>
> if foo returns a list of scalars >=2 this is like parameter
> unpacking:
>
> my ($head, [EMAIL PROTECTED]) = *foo();
Hi,
Yuval Kogman wrote:
> On Sat, Aug 27, 2005 at 14:29:29 +0200, Ingo Blechschmidt wrote:
>> * @foo[$idx] := $var;
>> my @bar = @foo;
>> $var= $new_var;
>> # @foo[$idx] and $var are now $new_var, but @bar is unchanged,
>> # right?
>
>
Hi,
Yuval Kogman wrote:
> On Sat, Aug 27, 2005 at 17:38:26 +0200, Ingo Blechschmidt wrote:
>> ($foo, $bar)[0] =:= $foo;
>> # False (i.e. no difference to arrays) or true?
>
> I think this is true, because you can say:
>
> ($foo, $bar) = (1, 2);
>
> And mor
Hi,
(sorry for me going into implementation details, but, as it's really a
language design question, I refrained from sending this to p6c.)
While trying to make the following work in PIL2JS...
my ($head, @tail) = foo();
it occured to me that this is bogus, or at least hard to implement.
Wi
Hi,
* my @array = ;
@array[1] = "new";
# Array elements are, of course, new (rw) containers.
* my @array = ($foo, $bar);
@array[0] =:= $foo;
# False -- array element are new containers.
@array[0] = $baz;
# $foo unchanged
I think these semantics are pretty clear. But what about lis
Ingo Blechschmidt wrote:
> Then we wondered what should happen to array elements which are bound
> to other variables if some things happen to the array. (Of course, the
> same thoughts apply to hashes as well).
Two more questions:
* @array[$out_of_bounds_index] := $var;
# Fatal erro
Hi,
with PIL-Run (Perl 6 to Perl 5 compiler) progressing rapidly, the topic
"binding" came up on #perl6.
"Binding is a simple symbol table manipulation, right?"
"No, consider @array[$idx] := $var or more generally
$sub(@args) := $var."
Then we wondered what should happen to array elements
Hi,
Yuval Kogman wrote:
> On Thu, Aug 25, 2005 at 15:42:28 +0200, Ingo Blechschmidt wrote:
>> This section will contain all information needed:
>> * User-defined operators
>> * Other symbols exported by "is export"
>> * Exported macros
>
> Okay, t
Hi,
Yuval Kogman wrote:
> On Thu, Aug 25, 2005 at 11:16:56 -, David Formosa (aka ? the
> Platypus) wrote:
>> On Wed, 24 Aug 2005 16:13:03 +0300, Yuval Kogman
>> <[EMAIL PROTECTED]> wrote:
>> > perl6 creates a new instance of the perl compiler (presumably an
>> > object). The compiler will only
Hi,
Yuval Kogman wrote:
> I think this is more consistent, and just as useful:
>
> 10 == 10; # dispatches to num
> "10" == 10; # dispatched to Num, by means of coercion (== has some
> affinity to it for backwards compatibility) "10" == "10"; # dispatches
> to Str, due to better match "10.0" == "1
Hi,
(asking because a test testing for the converse was just checked in to
the Pugs repository [1])
sub foo ($n, *%rest) {...}
foo 13;
# $n receives 13, of course, %rest is ()
foo 13, foo => "bar";
# $n receives 13 again, %rest is (foo => "bar")
foo n => 13;
# $n re
Hi,
Yiyi Hu wrote:
> my( $s, $t ); $s = "value t is $t"; $t = "xyz"; print $s;
> in perl 5, it will give a warning, and won't do "right" thing.
> we have to use other way or eval '$s' before print to get a "correct"
> answer.
>
> So I wonder, If we can make $scalar lazy also. As array now is lazy
Hi,
Larry Wall wrote:
> On Sat, Aug 20, 2005 at 10:33:03PM +0000, Ingo Blechschmidt wrote:
> : S02 says:
> : our $a; say $::("a"); # works
> :
> : my $a; say $::("a"); # dies, you should use:
> : my $a; say $::("MY::a");
Hi,
on #perl6, we were wondering how to use() modules from foreign
languages which have an incompatible identifier syntax. E.g.:
use perl5:Foo::Bar; # fine, no problem
# Load JavaScript modules from JSAN
use jsan:Test.Simple; # should we simply accept the dot, or...
Hi,
Luke Palmer wrote:
> sub foo (+$a, *%overflow) {
> say "%overflow{}";
> }
>
> foo(:a(1), :b(2)); # b2
> foo(:a(1), :overflow{ b => 2 }); # b2
I'd think so, too.
> foo(:a(1), :overflow{ b => 2 }, :c(3)); # ???
Error:
Hi,
Yuval Kogman woobling.org> writes:
> On Sat, Aug 20, 2005 at 22:27:56 +, Ingo Blechschmidt wrote:
> > > Not &code, but the return value of &code.emit
> >
> > Hm, Str? Or possibly a subtype of Str, allowing:
>
> I would guess an
Hi,
S02 says:
our $a; say $::("a"); # works
my $a; say $::("a"); # dies, you should use:
my $a; say $::("MY::a"); # works
How can I use symbolic dereferentiation to get $?SELF, $?CLASS,
::?CLASS, %MY::, etc.?
say $::('$?SELF');# does this work?
Hi,
Yuval Kogman woobling.org> writes:
> On Thu, Aug 18, 2005 at 12:24:40 +, Ingo Blechschmidt wrote:
> > Yuval Kogman woobling.org> writes:
> > > So now that the skeptics can see why this is important, on the
> > > design side I'd like to ask f
Hi,
Yuval Kogman woobling.org> writes:
> So now that the skeptics can see why this is important, on the
> design side I'd like to ask for ideas on how the code serialization
> looks...
>
> sub { $?DOM.document.write("hello world!") }.emit(
> :runtime($browser_autodetect_object),
>
Hi,
Stevan Little wrote:
> So, onto my question, I am wondering what are the valid scopes for
> $?SELF and $?CLASS.
>
> Are these (magical) globals who only have bound values in certain
> contexts? If that is so, what value do they have outside of a valid
> context? undef? or is attempting to acc
Hi,
1_234; # surely 1234
1e23; # surely 1 * 10**23
1._5; # call of method "_5" on 1?
1._foo; # call of method "_foo" on 1?
1.e5; # 1.0 * 10**5?
1.efoo; # call of method "efoo" on 1?
1.e_foo;# call of method "e_foo" on 1?
0xFF.de
Hi,
Nicholas Clark wrote:
> On Tue, Jun 14, 2005 at 07:56:32PM +0200, Ingo Blechschmidt wrote:
>> Maybe we should just hardcode the filehandles-leaking-into-runtime
>> case in the compiler? And, if the compiler can't detect the problem
>> at compile-time, just
Hi,
my $str = "Hello";
$str.ref = Int; # allowed?
$str.meta = &some_sub.meta; # allowed?
my $str = "Hello";
Str ::= Int; # allowed?
::Str ::= ::Int;# or is this allowed?
say $str; # still "Hello"?
Hi,
~Str;# ""? "Str"?
~::Str; # ""? "Str"?
~Str.meta; # ""? (fill in please)?
~::Str.meta; # ""? (fill in please)?
+Str; +::Str;
+Str.meta; +::Str.meta; # all errors?
?Str;
Hi,
Luke Palmer wrote:
> On 8/4/05, Ingo Blechschmidt <[EMAIL PROTECTED]> wrote:
>> my $pair = (a => 1);
>> say $pair[0]; # a?
>> say $pair[1]; # 1?
>>
>> I've found this in the Pugs testsuite -- is it legal?
>
> Nope.
Hi,
Andrew Shitov wrote:
>> say $pair[0]; # a?
>
> It looks like $pair is an arrayref while 'say ref $pair' tells 'Pair'.
right, this is why I asked, IMHO it's bogus.
> And may I ask a relating question:
>
> my $pair = ('name' => 'age');
> say $pair{'name'}; # prints 'age'
> say $pair['na
Hi,
(found in the Pugs testsuite.)
my $undef = undef;
say $undef.chars? # 0? undef? die?
say chars $undef; # 0? undef? die?
I'd opt for "undef.chars" to be an error ("no such method") and "chars
undef" to return 0 (with a warning printed to STDERR^W$*ERR).
Opinions?
--Ingo
--
Hi,
my $pair = (a => 1);
say $pair[0]; # a?
say $pair[1]; # 1?
I've found this in the Pugs testsuite -- is it legal?
--Ingo
--
Linux, the choice of a GNU | Black holes result when God divides the
generation on a dual AMD | universe by zero.
Athlon!|
Hi,
TSa (Thomas Sandlaß orthogon.com> writes:
> Ingo Blechschmidt wrote:
> > say zip (@odd, @even); # &zip gets only one argument, the flattened
> > # list ( @odd, @even), containing the
>
> Why flattened? Shouldn't that be *
Hi,
"TSa (Thomas Sandlaß)" wrote:
> Ingo Blechschmidt wrote:
>> Is this a bug in S29 or will this be feature removed from Perl 6
>> and you'll have to say (for example)
>>
>> use listops :mutating;
>> my @result = map { $_++; 42 } @array; #
Hi,
Andrew Shitov wrote:
> I tried zip under pugs.
>
> my @odd = (1, 3, 5, 7);
> my @even = (2, 4, 6, 8);
> my @bothA = zip @odd, @even;
> print @bothA;
>
> This code prints 12345678 as expected.
>
> After parenthesis were used to group zip arguments, results changes
> to 135724
Hi,
according to S29 [1], neither map nor grep allow mutation:
multi sub Perl6::Array::map (@values, Code $expression) returns Lazy
multi sub Perl6::List::map (Code $expression : [EMAIL PROTECTED]) returns
Lazy
multi sub Perl6::Array::grep (@values : Code *&test ) returns
Hi,
Larry Wall wrote:
> On Sat, Jul 30, 2005 at 02:14:52PM +0200, Ingo Blechschmidt wrote:
> : http://use.perl.org/~autrijus/journal/25337:
> : > deref is now 0-level; $x = 3; $y = \$x; $y++. # now an exception
> :
> : my $arrayref = [1,2,3];
[...]
> : s
Hi,
quick question:
my $pair = (a => 1);
say ~$pair;
I assume that outputs "a\t1", because of the "pairs can pretend to be
one-element hashes"-rule. Correct?
--Ingo
--
Linux, the choice of a GNU | We are Pentium of Borg. Division is futile.
generation on a dual AMD | You will be ap
Hi,
Larry Wall wrote:
> Except that you've rebound the container. Hmm, maybe the original
> binding is an error.
what about:
sub foo (Array $arrayref) {...}
my @array = ;
foo @array;
The binding used by the parameter binding code does not use the
standard := operator then, right?
Hi,
Larry Wall wrote:
> On Sat, Jul 30, 2005 at 02:33:15PM +0200, Ingo Blechschmidt wrote:
> : my @array = ;
> : my $arrayref := @array;
[...]
> : $arrayref = 42;# !!! 42 is not a Ref of Array
> :
> : Should the last line be treated as
>
Hi,
is binding hashes to arrays (or arrays to hashes) legal? If not, please
ignore the following questions :)
my @array = ;
my %hash := @array;
say %hash; # b
push @array, ;
say %hash; # f?
%hash = "Y";
say [EMAIL PROTECTED]; # ???
# (o
Hi,
my @array = ;
my $arrayref := @array;
push $arrayref, "c";
say [EMAIL PROTECTED]; # a b c d, no problem
$arrayref = [];
say [EMAIL PROTECTED]; # d e f, still no problem
$arrayref = 42;# !!! 42 is not a Ref of Array
Sho
Hi,
http://use.perl.org/~autrijus/journal/25337:
> deref is now 0-level; $x = 3; $y = \$x; $y++. # now an exception
my $arrayref = [1,2,3];
say $arrayref.ref;# Ref or Array?
say $arrayref.isa("Ref"); # true or false?
say $arrayref.isa("Array"); # false or true?
Hi,
are the following assumptions correct?
sub foo ([EMAIL PROTECTED]) { push @args, 42 }
sub bar ([EMAIL PROTECTED] is rw) { push @args, 42 }
foo @some_array; # dies ("Can't modify constant array...")
bar @some_array;
# works, but does not change @some_array, as the
Hi,
Luke Palmer wrote:
> http://repetae.net/john/recent/out/supertyping.html
>
> This was a passing proposal to allow supertype declarations in
> Haskell. I'm referencing it here because it's something that I've had
> in the back of my mind for a while for Perl 6. I'm glad somebody else
> has t
Hi,
are the following assumptions correct?
sub foo ([EMAIL PROTECTED]) { @args[0] }
say ~foo("a", "b", "c"); # "a"
my @array = ;
say ~foo(@array);# "a b c d" (or "a"?)
say ~foo(@array, "z"); # "a b c d" (or "a"?)
say ~foo([EMAIL PROTECTED]); # "a"
s
Hi,
according to Damian [1]...:
my %hash = (a => 1, b => 2);
my @array = %hash;
say @array[0].isa(Pair); # true
How can I override this behaviour?
class MyHash is Hash {
# Please fill in here
}
my %hash is MyHash = (a => 1, b => 2);
my @array = %h
Hi,
# Perl 5
my %hash = (a => 1, b => 2, a => 3);
warn $hash{a}; # 3
But I vaguely remember having seen...:
# Perl 6
my %hash = (a => 1, b => 2, a => 3);
say %hash;# 1
Can somebody confirm this?
--Ingo
--
Linux, the choice of a GNU | Mathematicians practice abs
Hi,
class Foo {...}
Foo.new.isa(Foo); # true
Foo.isa(Foo); # true (see [1])
Foo.does(Class);# true
sub blarb (Foo $foo, $arg) {
...; # Do something with instance $foo
}
blarb Foo.new(...), ...;
# No problem
blarb Foo,
Hi,
Michele Dondi wrote:
>> Good, I'd forgotten about that. Which means that it's even harder
>> for someone to compile a module in a "strange" dialect, since they'd
>> essentially have to write their own version of "use" that forces
>> recompilation ("reuse", if you will). And the harder we mak
Hi,
what do use and require evaluate to?
S06 suggests it's probably some kind of Module object:
The result of a use statement is a (compile-time) object that also has
an .assuming method, allowing the user to bind parameters in all the
module's subroutines/methods/etc. si
Hi,
Larry Wall wrote:
> On Mon, Jul 11, 2005 at 09:46:30AM -0400, Stevan Little wrote:
> : On Jul 11, 2005, at 9:16 AM, Ingo Blechschmidt wrote:
> : > Bar.isa(Object);# true
> : > Bar.isa(Class); # true
> : > Bar.isa(Foo); # ? (my guess: f
Hi,
Stevan Little wrote:
> Actually I was thinking that MyClass.isa(...) would work much as it
> did in Perl 5 (like an instance). But that access to the underlying
> MyClass class instance would not be as simple. Something like
> ::MyClass would provide access to the Class instance.
>
>class
Hi,
Stevan Little wrote:
> On Jul 11, 2005, at 9:16 AM, Ingo Blechschmidt wrote:
>> Bar.isa(Object);# true
>> Bar.isa(Class); # true
>> Bar.isa(Foo); # ? (my guess: false)
>> Bar.isa(Bar); # ? (my guess: false)
>
>
Hi,
my $x = 42;
my $y = $x;
$y++;
say $x; # Still 42, of course
class Foo {
has $.data;
method incr () { $.data++ }
# Please fill in appropriate magic here
}
my Foo $x .= new(:data(42));
my Foo $y = $x;
$y.incr();
say $x.data;# Should still be 42
Hi,
class Foo {}
class Bar is Foo {}
Bar.new.isa(Object);# true
Bar.new.isa(Class); # false
Bar.new.isa(Foo); # true
Bar.new.isa(Bar); # true
# These are clear, I think.
Bar.isa(Object);# true
Bar.isa(Class); # true
Bar.isa(Foo);
Hi,
Juerd wrote:
> Ingo Blechschmidt skribis 2005-07-05 20:08 (+0200):
>> FWIW, I agree, but I'd like to propose standard overloadings:
>> say ~$time; # "Di 05 Jul 2005 20:01:42 CEST"
>
> Or perhaps not. In fact, rather not. Please let string
Hi,
Dave Whipp wrote:
> Larry Wall wrote:
>> The time function always returns the time in floating point.
>
> I don't understand why time() should return a numeric value at all.
> Surely it should return a DateTime (or Time) object. Using epochs in a
> high level language seems like a really bad
Hi,
.assuming is non-mutating on Code objects:
my $subref = &some_sub;
my $assumed_subref = $subref.assuming(:foo);
$subref =:= &some_sub;# true, $subref did not change
Quoting S06:
> The result of a use statement is a (compile-time) object that also
> has an .assuming method,
Hi,
Juerd convolution.nl> writes:
> Piers Cawley skribis 2005-06-23 15:30 (+0100):
> > Brent 'Dax' Royal-Gordon gmail.com> writes:
> > > As I've said before, Perl supports `alias`--it's just spelled `:=`.
> > Here's a rubyish idiom:
> > my &old_behaviour := &function;
> > &function :
Hi,
Juerd wrote:
> Ingo Blechschmidt skribis 2005-06-15 20:18 (+0200):
>> >> say join ",", @words; # "hi,my,name,is,ingo";
>> > Following the logic that .words returns the words, the words are no
>> > longer individual words when join
1 - 100 of 166 matches
Mail list logo