Apocalypse 6: IDs of subroutine wrappers should be objects

2004-06-08 Thread Ingo Blechschmidt
(...); ...; $canvas-raise($id); # Better: $id-raise; Sorry if this was discussed before, didn't found anything. Ingo Blechschmidt

Re: Instantiation

2004-08-23 Thread Ingo Blechschmidt
).new(...); If Cuse's argument is a Module object, Cuse should return the first class of that module. I like the Cuse(...).new(...) form the best, because it allows you to pass parameters to Cnew. Ingo Blechschmidt -- Linux, the choice of a GNU | Running Windows on a Pentium is like having

Re: CLI signature?

2005-02-05 Thread Ingo Blechschmidt
Hi, Juerd wrote: This probably goes against everything a shell based platform wants, but would it be possible to give the program a sub-like signature? I like that idea very much, but... signature ( Rule $pattern, bool +$help:short('h'), Int +$verbose

Re: CLI signature?

2005-02-05 Thread Ingo Blechschmidt
Hi, Juerd wrote: Ingo Blechschmidt skribis 2005-02-05 17:19 (+0100): ...this seems a bit ugly to me. The signature part, or the signature itself? Because you'll encounter lists like this all over Perl 6 code anyway... I refered to the way the signature is specified, not the signature

Re: S06: Pairs as lvalues

2005-02-27 Thread Ingo Blechschmidt
Hi, Luke Palmer luke at luqui.org writes: Ingo Blechschmidt writes: my $x = (a = 42); # $x is a Pair. $x = 13; # Is $x now the Pair (a = 13) or # the Int 13? You see, in your example, the pair is not functioning as an lvalue. The variable

ceil and floor in the core?

2005-03-22 Thread Ingo Blechschmidt
Hi, a quick question: Will ceil and floor be in the core of Perl 6? I vaguely remember that being in the case, but it's not in the Synopses. (For comparision, in Perl 5 they're in POSIX.pm.) --Ingo

[S29] pick on other things than junctions

2005-04-04 Thread Ingo Blechschmidt
Hi, I remembered Damian saying that pick does not only work on junctions, but on arrays and hashes, too (and I even found his posting :): http://groups.google.com/groups?selm=420DB295.3000902%40conway.org). Are the following assumptions correct? my $junc = 1|2|3; print $junc.pick; # 1, 2,

Re: [S29] pick on other things than junctions

2005-04-05 Thread Ingo Blechschmidt
Hi, Trey Harris wrote: In a message dated Mon, 4 Apr 2005, Ingo Blechschmidt writes: What does pick return on hashes? Does it return a random value or a random pair? (I suppose returning a pair is more useful.) I'd assume in all cases that pick returns an *alias*, and in the case of hashes

Re: [S29] pick on other things than junctions

2005-04-05 Thread Ingo Blechschmidt
Hi, Larry Wall wrote: : Same for hashes: [...] : my %hash = (a = 1, b = 2), : my $pair := %hash.pick; : $pair = ...; # %hash changed I'm not sure that works. We don't quite have pairs as first class containers. Binding would try to use a pair as a named argument, and would fail

[S29] update (was: Re: Question about $pair.kv)

2005-04-10 Thread Ingo Blechschmidt
Hi, Luke Palmer luke at luqui.org writes: Stevan Little writes: One tests shows $pair.kv returning an array with two elements (the key and value of the pair). (This is also how Pugs currently implements this.) The former is certainly correct. When all else fails, consider a

[S06] Types of subroutines/blocks/etc.

2005-04-10 Thread Ingo Blechschmidt
Hi, A06 states: Code | | | RoutineBlock |_____|___ | | | || |

Re: Question about list context for String.chars

2005-04-11 Thread Ingo Blechschmidt
Hi, gcomnz wrote: I'm writing a bunch of examples for perl 6 pleac and it seems rather natural to expect $string.chars to return a list of unicode chars in list context, however I can't find anything to confirm that. (The other alternatives being split and unpack.) I like that. If one

How do I... tie hashes/arrays?

2005-04-19 Thread Ingo Blechschmidt
Hi, quoting an old post from Luke (http://xrl.us/ftet): Ctieing is going to work quite differently, from what I hear. So it might be possible to overload any function to call a special version when your type of array is used. You just have to write all the special versions.

Re: { = } autocomposition

2005-04-20 Thread Ingo Blechschmidt
Hi, Autrijus Tang wrote: %ret = map { $_ = uc $_ }, split , $text; [...] I suppose my test is wrong. When I clicked on reply a moment ago, I wanted to propose to change the hash/code disambiguation rule, so that {...} is always parsed as Code if the body contains $_ or $^ But as this

Re: Thunking semantics of :=

2005-04-23 Thread Ingo Blechschmidt
Hi, Autrijus Tang wrote: my ($x, @a); $x := @a[0]; @a := ($x, $x, $x); $x := 1; say @a; # (undef, undef, undef) hm, I'd expect @a to be (1, 1, 1) (WE = when evaluated): my ($x, @a);# $x is undef WE, @a is () WE $x := @a[0];# $x is undef WE, @a is ()

Binding and the Proxy class

2005-04-23 Thread Ingo Blechschmidt
Hi, my $x = new Proxy: FETCH = { foo() }, STORE = { bar($^new) }; $x ~~ Proxy; # true $x = 42; # neither foo nor bar called $x ~~ Num; # true my $y := new Proxy: FETCH = { foo() }, STORE = { bar($^new) }; $y ~~ Proxy; # false (unless foo returns a Proxy object) $y = 42; #

is rw basically a null-op on objects/references?

2005-04-28 Thread Ingo Blechschmidt
Hi, does the following work as expected? for %hash.pairs - $pair { # Note: No is rw! $pair.value = ...; # Modifies %hash } Or is it necessary to declare $pair as is rw? (The snippet does not modify $pair, but $pair.value.) --Ingo -- Linux, the choice of a GNU | The next

Re: [S29] pick on other things than junctions

2005-04-28 Thread Ingo Blechschmidt
Ingo Blechschmidt iblech at web.de writes: then it has a better chance of working, presuming someone has the gumption to write .pick on hashes, which doesn't look entirely trivial to do right. thinking out loudI'm sure I overlooked something, but the following seems to be correct

Junctions of classes, roles, etc.

2005-04-28 Thread Ingo Blechschmidt
Hi, so we had junctions of Code references some days ago, what's with junctions of Class and Role objects? :) role A { method foo() { 42 } } role B { method foo() { 23 } } class Test does A|B {} my Test $test .= new; my $ret = $test.foo; # 42|23? role A {} role B { method

Re: Adding Complexity

2005-04-28 Thread Ingo Blechschmidt
Hi, Essentially lazy lists are suspended closures. But I dought that arithmetic between them is defined such that pi + pi would leazily calculate 6.28... ...which makes me wonder if it'd be good|cool|whatever to not only have lazy lists, but also lazy *values*...: :)) my $pi =

Re: Adding Complexity

2005-04-28 Thread Ingo Blechschmidt
Ingo Blechschmidt wrote: And: my @ones = gather { take 1 while 1 }; my $ones = join , @ones; # does not burn out! say length $ones; # Inf s/length/chars/ of course. --Ingo -- Linux, the choice of a GNU | God said: tar xvjf universe.tar.gz - and generation on a dual AMD

Re: Adding Complexity

2005-04-28 Thread Ingo Blechschmidt
Hi, Luke Palmer wrote: ...which makes me wonder if it'd be good|cool|whatever to not only have lazy lists, but also lazy *values*...: :)) Then every expression that referenced lazy values would be lazy in terms of them. And once you want to print X digits of the lazy answer, you have to

Re: Code classes

2005-05-02 Thread Ingo Blechschmidt
Hi, Thomas Sandla wrote: the main reason for this mail: aliasing $_ in methods to the first invocant would badly mix these two concepts! I think so, too. I'd like to see: $.foo# attribute of $?SELF @.foo# ditto %.foo# ditto .foo# method of $?SELF .foo#

Re: Coroutine Question

2005-05-04 Thread Ingo Blechschmidt
Hi, Joshua Gatcomb wrote: On 5/4/05, Luke Palmer [EMAIL PROTECTED] wrote: On 5/4/05, Joshua Gatcomb [EMAIL PROTECTED] wrote: So without asking for S17 in its entirety to be written, is it possible to get a synopsis of how p6 will do coroutines? I ask because after reading Dan's What the

Re: Cmmposition binop

2005-05-04 Thread Ingo Blechschmidt
Hi, Rob Kinyon wrote: What about the function compose() that would live in the module keyword, imported by the incantation use keyword qw( compose );? FWIW, I like o better -- function composing is very often used in FP, and should therefore have a short name. Luckily, it's very easy to

Declaration and definition of state() vars

2005-05-05 Thread Ingo Blechschmidt
Hi, sub gen() { state $svar = 42; # Only initialized once, as it is (per S04) equivalent to # state $svar will first{ 42 }; return { $svar++ }; } my $a = gen();# $svar == 42 $a(); $a(); # $svar == 44 my $b = gen();# $svar == 44 say $b(); # 44

Scoping of $/

2005-05-10 Thread Ingo Blechschmidt
Hi, sub foo() { abc ~~ /^(.)/; # $1 now a } sub bar() { def ~~ /^(.)/; # $1 now d foo(); say $1;# Outputs d } bar(); # Correct (I hope so)? --Ingo -- Linux, the choice of a GNU | Row, row, row your bits, gently down the

BUILD and other submethods

2005-05-16 Thread Ingo Blechschmidt
Hi, class Foo { submethod BUILD() { say 42; } } class Bar is Foo { submethod BUILD() { say 23; } } my Bar $bar .= new; I suppose this will output: 42 23 S12 says that submethod[s] [are] called only when a method call is dispatched

Roles and BUILD

2005-05-16 Thread Ingo Blechschmidt
Hi, are Roles allowed to contain submethods and does especially the BUILD submethod work as I presume in the following code? class IRC::Bot { has Array %:handler; method add_handler(Str $event, Code $callback) { push %:handler{$event}: $callback; } ...;

Re: ^method ?

2005-05-16 Thread Ingo Blechschmidt
Hi, wolverian wrote: On Mon, May 16, 2005 at 02:26:02PM -0400, Matt Fowles wrote: $.foo @.foo %.foo and their ilk operate on the current invocant, $?SELF. This leads naturally toward .foo also refering to $?SELF. But as we all know the is optional on function calls... I believe you

Default precedence level of user defined infix ops

2005-05-18 Thread Ingo Blechschmidt
Hi, now that the following works in Pugs :)... sub infix:. (Code x, Code y) { sub ($z) { x(y($z)) } } (say . int)(10/3);# 3 use Set; sub infix: ($item, @set) { set(@set).includes($item); } foo bar baz foo; # true 23 bar baz foo; # false ...we wondered

Syntax for specifying role parameters

2005-05-19 Thread Ingo Blechschmidt
Hi, I wondered if it would be useful/good/nice if the syntax for specifying role parameters would be the same as the standard subroutine signature syntax (minus the colon, which separates the parameters which do account to the long name of the role from the ones which don't). E.g.:

Re: Syntax for specifying role parameters

2005-05-19 Thread Ingo Blechschmidt
Hi, TSa (Thomas Sandla) wrote: you wrote: I wondered if it would be useful/good/nice if the syntax for specifying role parameters would be the same as the standard subroutine signature syntax (minus the colon, which separates the parameters which do account to the long name of the role from

[S29] uniq

2005-05-19 Thread Ingo Blechschmidt
Hi, three quick questions: Is it intentional that there's no uniq in the current S29[1] draft? See [2] for Damian saying that uniq is probably in. I wondered what uniq's default comparator should be, =:=? Should it be possible to give an own comparator block, similar as with grep? E.g. uniq

Re: [S29] uniq

2005-05-19 Thread Ingo Blechschmidt
Hi, Rod Adams wrote: I wondered what uniq's default comparator should be, =:=? I'd have gone with ~~ Even better. :) --Ingo -- Linux, the choice of a GNU | Row, row, row your bits, gently down the generation on a dual AMD | stream... Athlon!|

s/.../{ $junction }/

2005-05-19 Thread Ingo Blechschmidt
Hi, while writing a preliminary p6explain, I wondered if the following should work: my $text = aBc; $text ~~ s/B/{ C|D }/; say $text.values; # aCc aDc This would be extremely handy for p6explain, as I'm currently parsing a datafile which looks like... + Standard mathematical infix

Re: [S29] uniq

2005-05-19 Thread Ingo Blechschmidt
Hi, Mark Overmeer wrote: * Ingo Blechschmidt ([EMAIL PROTECTED]) [050519 16:52]: Should it be possible to give an own comparator block, similar as with grep? E.g. uniq a b a a c d; # a b a c d uniq:{ abs $^a == abs $^b } 42, 23, -23, 23, 42 # 42, 23, 42

Re: [S29] uniq

2005-05-19 Thread Ingo Blechschmidt
Hi, Adriano Ferreira wrote: quoting Damian's original mail[1]: uniq - remove duplicates without reordering ^^ Would not that mean the original order of the first ocurrence is preserved? This is what Ruby Array#uniq does:

How do I... create a new meta operator?

2005-05-19 Thread Ingo Blechschmidt
Hi, quoting A12: infix_postfix_meta_operator:= $x += 2; postfix_prefix_meta_operator:{''} @array ++ prefix_postfix_meta_operator:{''} - @magnitudes infix_circumfix_meta_operator:{'',''} @a + @b so will the following work? # Silly example sub

How do I... invoke a method reference

2005-05-19 Thread Ingo Blechschmidt
Hi, class Foo { method bar() { 42 } method baz() { bar } } my $ref = Foo.baz; $ref(); # Don't think this will work # (Error: No invocant specified or somesuch) $ref(Foo.new); # But will this work? How do I specify multiple invocants (when dealing

Re: [S29] uniq

2005-05-19 Thread Ingo Blechschmidt
Hi, Damian Conway wrote: BTW, I am *sorely* tempted to suggest the following implementation instead: [...] which would produce: uniq a b a a c d; # a b c d uniq { lc } a b C A a c d; # 'a'|'A', 'b', 'C'|'c', 'd' uniq { abs

Declaration of my() variables using symbolic referentiation

2005-05-21 Thread Ingo Blechschmidt
Hi, am I correct in the assumption that the following is an error? # Not in a BEGIN block my $::(calc_varname()) = 42; I think so, as my() is a compile-time operation, but in this example, the variable name is not known until runtime, so I think this should be forbidden. Correct?

Re: lazy context

2005-05-23 Thread Ingo Blechschmidt
Hi, Yuval Kogman nothingmuch at woobling.org writes: we have a lazy modifier: my $a = lazy { get_value(5, 10) }; as of r3739 implemented in Pugs. :) The only builtin feature that needs to be added is that coroutines can masquerade as their return value, and not a code

Declarations of constants

2005-05-27 Thread Ingo Blechschmidt
Hi, # Way 1 my $MEANING_OF_LIFE is constant = 42; # Way 2 my MEANING_OF_LIVE = - () { 42 }; # or sub MEANING_OF_LIVE () { 42 } # Then one can use sigilless constants: say MEANING_OF_LIVE; # Way 3 (still possible?) use constant MEANING_OF_LIVE = 42; # Way 4 (evil?)

Re: Declarations of constants

2005-05-27 Thread Ingo Blechschmidt
Hi, TSa (Thomas Sandla) wrote: my MEANING_OF_LIVE = 42; # But might be considered evil sigilless mode is that allowed (as 42 is a Num (or an Int), not a Code)? Do (most of) the basic types morph themselves into Codes, when needed? say 42();# 42? say Perl();#

Re: Declarations of constants

2005-05-27 Thread Ingo Blechschmidt
Hi, TSa (Thomas Sandla) wrote: Ingo Blechschmidt wrote: Or did you simply forget the braces around 42? :) No, it was intented for seeing what the reactions will be :) :) Just using foo as unsigiled variable. This might need my foo is rw; I don't think this will DWYW, as firstly is rw

Default invocant of methods

2005-05-27 Thread Ingo Blechschmidt
Hi, what is the default invocant of methods? method blarb ($normal_param) {...} # Same as method blarb (Class | ::?CLASS $invocant: $normal_param) {...} # or method blarb (::?CLASS $invocant: $normal_param) {...} # ? I prefer the latter, as then one can't accidentally call a

Re: Anonymous classes

2005-05-29 Thread Ingo Blechschmidt
Hi, Simon Cozens wrote: I'm having a seriously good time porting Maypole to Perl 6. If you still have reservations about how Perl 6 is going to be to program in, I urge you to try programming in it. Now, commercial over, I have some questions. :) class Foo { has Class

Re: function signatures?

2005-05-29 Thread Ingo Blechschmidt
Hi, Yuval Kogman wrote: We have a pretty complex declarative language for argument processing in the parameter declaration: [...] arity as a number does not give enough reflection into these properties. Indeed. Are signatures going to be an exposed first class object in Perl 6? I hope so,

Fully introspectable Code objects?

2005-05-29 Thread Ingo Blechschmidt
Hi, while responding to nothingmuch++'s post function signatures?, I thought that it'll be great if Code objects were fully introspectable. I.e.: foo.statements; # List of statements foo.statements[0] # First statement foo.statements[2] = ...;# Statement

Re: Anonymous classes

2005-05-29 Thread Ingo Blechschmidt
Hi, Simon Cozens wrote: [EMAIL PROTECTED] (Ingo Blechschmidt) writes: I think the only thing you're missing are two braces: $.request_class = class is Foo::Request {}; Thank you; then how do I put methods into $.request_class? $.request_class = class is Foo::Request { method blarb

Quick questions: multi submethod and undef.method

2005-06-05 Thread Ingo Blechschmidt
Hi, two quick questions: Are multi submethods allowed? my $x = undef; my $y = $x.some_method; # $y now contains an unthrown exception object, saying that undef # doesn't .can(some_method), right? say $y; # Only now it dies, correct? This is important if you have a sub which may

return() in pointy blocks

2005-06-07 Thread Ingo Blechschmidt
Hi, sub foo (Code $code) { my $return_to_caller = - $ret { return $ret }; $code($return_to_caller); return 23; } sub bar (Code $return) { $return(42) } say foo bar; # 42 or 23? I think it should output 42, as the return() in the pointy block $return_to_caller

Re: return() in pointy blocks

2005-06-07 Thread Ingo Blechschmidt
Hi, Matt Fowles wrote: On 6/7/05, Ingo Blechschmidt [EMAIL PROTECTED] wrote: sub foo (Code $code) { my $return_to_caller = - $ret { return $ret }; $code($return_to_caller); return 23; } sub bar (Code $return) { $return(42) } say foo bar; # 42 or 23? I think

BEGIN {...} and IO

2005-06-13 Thread Ingo Blechschmidt
Hi, # No problem: my $data = BEGIN { my $fh = open some_file err...; =$fh; }; # Problem; my $fh = BEGIN { open some_file err... }; # Compile-time filehandle leaked into runtime! say =$fh; In Perl 5, this wasn't a problem, as compilation and execution happended (most of the

Anonymous macros?

2005-06-13 Thread Ingo Blechschmidt
Hi, just checking: Are anonymous macros allowed? my $macro = macro ($x) { 100$x }; say $macro(3); # 1003 Of course, anonymous macros can't be called at compile-time, like normal macros: my $macro = rand 0.5 ?? macro ($x) { 100$x } :: macro ($x) { 200$x }; say $macro(3); # 1003

Re: BEGIN {...} and IO

2005-06-13 Thread Ingo Blechschmidt
Hi, chromatic wrote: On Mon, 2005-06-13 at 17:07 +0200, Ingo Blechschmidt wrote: # No problem: my $data = BEGIN { my $fh = open some_file err...; =$fh; }; # Problem; my $fh = BEGIN { open some_file err... }; # Compile-time filehandle leaked into runtime! say =$fh

Assigning Proxy objects

2005-06-14 Thread Ingo Blechschmidt
Hi, sub proxy () is rw { return new Proxy: FETCH = { 42 }, STORE = - $new { 23 }; } say proxy();# 42 say proxy() = 40; # 40, 23, or 42? Currently I think the last line should output 40, consider: sub innocent_sub ($var is copy) { my $foo =

Re: Creating a web templating engine

2005-06-14 Thread Ingo Blechschmidt
Hi, BRTHZI Andrs wrote: $wte = new WTE; $wte.register('input', my_input_widget); I don't prefer it, to be 20-30 register line in my programs, that does nothing, just register. maybe something like this? class MyWTE is WTE { method input (...) {...} method

Re: BEGIN {...} and IO

2005-06-14 Thread Ingo Blechschmidt
Ingo Blechschmidt wrote: # No problem: my $data = BEGIN { my $fh = open some_file err...; =$fh; }; # Problem; my $fh = BEGIN { open some_file err... }; # Compile-time filehandle leaked into runtime! say =$fh; [...] * There's a boolean property

Re: Hyper-concat

2005-06-14 Thread Ingo Blechschmidt
Hi, Thomas Klausner wrote: my $string=a b c ~ 1 2 3; say $string; # prints a1 b2 c3 But where do the spaces in the second example come from? the spaces come from the stringification of lists/arrays: my @array = a b c d; say [EMAIL PROTECTED];# a b c d You can use say

Lvalue Str::words iterator

2005-06-15 Thread Ingo Blechschmidt
Hi, as Larry mentioned in another thread that he wants a different notation for word splitting (http://www.nntp.perl.org/group/perl.perl6.language/21874), how about that, similar to Haskell's words function: # Str::words should return a list of words, without whitespace. my $str = hi

Re: Lvalue Str::words iterator

2005-06-15 Thread Ingo Blechschmidt
Hi, Juerd wrote: Ingo Blechschmidt skribis 2005-06-15 19:14 (+0200): as Larry mentioned in another thread that he wants a different notation for word splitting (http://www.nntp.perl.org/group/perl.perl6.language/21874), how about that, similar to Haskell's words function: words is wrong

Re: Lvalue Str::words iterator

2005-06-15 Thread Ingo Blechschmidt
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 joined on comma instead of whitespace... sorry, I don't quite get

Re: proposal: binding with a function

2005-06-23 Thread Ingo Blechschmidt
Hi, Juerd juerd at convolution.nl writes: Piers Cawley skribis 2005-06-23 15:30 (+0100): Brent 'Dax' Royal-Gordon brentdax at gmail.com writes: As I've said before, Perl supports `alias`--it's just spelled `:=`. Here's a rubyish idiom: my old_behaviour := function;

Should .assuming be always non-mutating?

2005-07-04 Thread Ingo Blechschmidt
Hi, .assuming is non-mutating on Code objects: my $subref = some_sub; my $assumed_subref = $subref.assuming(:foobar); $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,

Re: Time::Local

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

Re: Time::Local

2005-07-05 Thread Ingo Blechschmidt
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 stringification be the ISO standard, and otherwise

Re: Quick OO .isa question

2005-07-11 Thread Ingo Blechschmidt
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) I am not sure about this. I think that .isa

Re: Quick OO .isa question

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

Re: Quick OO .isa question

2005-07-11 Thread Ingo Blechschmidt
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: false) : Bar.isa(Bar

What do use and require evaluate to?

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

Re: User-defined infix subs/methods?

2005-07-13 Thread Ingo Blechschmidt
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 make it to

How do subroutines check types?

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

Hash creation with duplicate keys

2005-07-20 Thread Ingo Blechschmidt
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 %hasha;# 1 Can somebody confirm this? --Ingo -- Linux, the choice of a GNU | Mathematicians practice

User-defined behaviour of hashes in list context

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

Re: Messing with the type heirarchy

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

Slurpy is rw arrays ([EMAIL PROTECTED] is rw)

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

$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 = a b c; my $arrayref := @array; push $arrayref, c; say [EMAIL PROTECTED]; # a b c d, no problem $arrayref = [d e f]; say [EMAIL PROTECTED]; # d e f, still no problem $arrayref = 42;# !!! 42 is not a Ref of

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 = a b c d; my %hash := @array; say %hasha; # b push @array, e f; say %hashe; # f? %hashX = Y; say [EMAIL PROTECTED]; #

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 = a b c d; foo @array; The binding used by the parameter binding code does not use the standard := operator then,

Stringification of pairs

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

[S29] Mutating map and grep

2005-08-01 Thread Ingo Blechschmidt
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

Re: zip with ()

2005-08-01 Thread Ingo Blechschmidt
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 13572468. Is it

Re: [S29] Mutating map and grep

2005-08-01 Thread Ingo Blechschmidt
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; # works now Why not just my @result = map - $_ is rw

Re: zip with ()

2005-08-01 Thread Ingo Blechschmidt
Hi, TSa (Thomas Sandlaß Thomas.Sandlass at 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 *(@odd, @even)? IIUC

$pair[0]?

2005-08-04 Thread Ingo Blechschmidt
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!|

Re: $pair[0]?

2005-08-04 Thread Ingo Blechschmidt
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. That's: say $pair.key; say $pair.value; Also: say

Various questions on .ref and .meta

2005-08-05 Thread Ingo Blechschmidt
Hi, ~Str;# class? Str? ~::Str; # class? Str? ~Str.meta; # class? (fill in please)? ~::Str.meta; # class? (fill in please)? +Str; +::Str; +Str.meta; +::Str.meta; # all errors?

Reassigning .ref and .meta? Rebinding class objects?

2005-08-05 Thread Ingo Blechschmidt
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? Or is

Re: BEGIN {...} and IO

2005-08-13 Thread Ingo Blechschmidt
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 throw a runtime exception? my $fh

Re: scopes of $?SELF and $?CLASS

2005-08-17 Thread Ingo Blechschmidt
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

Re: Serializing code

2005-08-18 Thread Ingo Blechschmidt
Hi, Yuval Kogman nothingmuch at 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(phello world!/p) }.emit(

Re: Serializing code

2005-08-20 Thread Ingo Blechschmidt
Hi, Yuval Kogman nothingmuch at woobling.org writes: On Thu, Aug 18, 2005 at 12:24:40 +, Ingo Blechschmidt wrote: Yuval Kogman nothingmuch at 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

Symbolic dereferentiation of magical variables

2005-08-20 Thread Ingo Blechschmidt
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? say

Re: Serializing code

2005-08-21 Thread Ingo Blechschmidt
Hi, Yuval Kogman nothingmuch at 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 AST, that is, any object, that implements

Re: *%overflow

2005-08-21 Thread Ingo Blechschmidt
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: Too many

use language_with_different_indentifier_syntax:...

2005-08-22 Thread Ingo Blechschmidt
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...

Re: Symbolic dereferentiation of magical variables

2005-08-22 Thread Ingo Blechschmidt
Hi, Larry Wall wrote: On Sat, Aug 20, 2005 at 10:33:03PM +, Ingo Blechschmidt wrote: : S02 says: : our $a; say $::(a); # works : : my $a; say $::(a); # dies, you should use: : my $a; say $::(MY::a); # works That looks like somebody's relic of Perl 5 thinking

  1   2   >