sub foo ($x) returns ref($x)

2005-07-30 Thread Autrijus Tang
Suppose we have a function that takes an argument and returns something with the same type as that argument. One previous suggestion is this: sub identity ((::a) $x) returns ::a { return(...) } This is fine if both invariants in the "the meaning of 'returns'" thread are observed, since the i

&say's return value

2005-07-30 Thread Gaal Yahas
What do &print and &say return? "fail" would be great on errors. On success, they return "1" now, which doesn't look very useful. How about returning the printed string? Unless called in void context, of course. (This introduces a potential semipredicate problem when looking at the return value o

$arrayref.ref?

2005-07-30 Thread Ingo Blechschmidt
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?

Binding scalars to aggregates

2005-07-30 Thread Ingo Blechschmidt
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

Binding hashes to arrays?

2005-07-30 Thread Ingo Blechschmidt
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

Re: $arrayref.ref?

2005-07-30 Thread Larry Wall
On Sat, Jul 30, 2005 at 02:14:52PM +0200, Ingo Blechschmidt wrote: : 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? Array. : say

Re: Binding scalars to aggregates

2005-07-30 Thread Larry Wall
On Sat, Jul 30, 2005 at 02:33:15PM +0200, Ingo Blechschmidt wrote: : Hi, : : my @array = ; : my $arrayref := @array; : : push $arrayref, "c"; : say [EMAIL PROTECTED]; # a b c d, no problem : : $arrayref = []; : say [EMAIL PROTECTED]; # d e

Re: Binding scalars to aggregates

2005-07-30 Thread Larry Wall
Except that you've rebound the container. Hmm, maybe the original binding is an error. Larry

Re: Binding hashes to arrays?

2005-07-30 Thread Larry Wall
On Sat, Jul 30, 2005 at 02:59:02PM +0200, Ingo Blechschmidt wrote: : 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

Re: Binding scalars to aggregates

2005-07-30 Thread Ingo Blechschmidt
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 > : $arrayref = (42,); > : wh

Re: Binding scalars to aggregates

2005-07-30 Thread Ingo Blechschmidt
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?

Re: $arrayref.ref?

2005-07-30 Thread Aankhen
On 7/30/05, Larry Wall <[EMAIL PROTECTED]> wrote: > On Sat, Jul 30, 2005 at 02:14:52PM +0200, Ingo Blechschmidt wrote: > : say $arrayref.isa("Ref"); # true or false? > > False, though tied($arrayref).isa("Ref") is probably true. In that case, how do you check if something is a ref? `if (

Re: &say's return value

2005-07-30 Thread chromatic
On Sat, 2005-07-30 at 14:56 +0300, Gaal Yahas wrote: > (This introduces a potential semipredicate problem when looking at the > return value of a printed "0" or "" while not using "fatal", but the > code can use a defined guard.) I don't know if returning the printed string is the right approach,

Re: &say's return value

2005-07-30 Thread Larry Wall
On Sat, Jul 30, 2005 at 09:25:12AM -0700, chromatic wrote: : On Sat, 2005-07-30 at 14:56 +0300, Gaal Yahas wrote: : : > (This introduces a potential semipredicate problem when looking at the : > return value of a printed "0" or "" while not using "fatal", but the : > code can use a defined guard.)

Re: Binding scalars to aggregates

2005-07-30 Thread Larry Wall
On Sat, Jul 30, 2005 at 05:17:29PM +0200, Ingo Blechschmidt wrote: : 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

Re: &say's return value

2005-07-30 Thread Gaal Yahas
On Sat, Jul 30, 2005 at 09:36:13AM -0700, Larry Wall wrote: > I don't see any reason to return the string at all. It's almost never > wanted, and you can always use .= or monkey but. So: fail on failure bool::true on success? Pugs currently returns bool::true. Is there a way to tag a sub as fail

module init hooks and pragmas

2005-07-30 Thread Gaal Yahas
What gets called for me when someone "use"s my module? What gets called when someone "no"s it? L stipulates a standard syntax for import lists, and that's probably a good thing, but then how do you pass other compile-time requests to code that's being used? Perhaps in light of L, we can make "use

Re: Binding scalars to aggregates

2005-07-30 Thread Autrijus Tang
On Sat, Jul 30, 2005 at 09:40:11AM -0700, Larry Wall wrote: > Right, so I guess what really happens is ref autogeneration in that > case, and there's no difference between > > $x = @array; > $x := @array; > > Hey, who said anything about consistency? :-) Hm, not exactly. This form:

Re: Messing with the type heirarchy

2005-07-30 Thread Luke Palmer
On 7/27/05, Larry Wall <[EMAIL PROTECTED]> wrote: > On Wed, Jul 27, 2005 at 11:00:20AM +, Luke Palmer wrote: >> Everything that is a Num is a Complex right? > > Not according to Liskov. Num is behaving more like a constrained > subtype of Complex as soon as you admit that "isa" is about both