several
independent ones?
Joe Gottman
cuted. {} is an
empty subroutine that executes by doing absolutely nothing.
Joe Gottman
med_arg <- $value);
foo($value -> $named_arg);
Which one of these two is better depends on whether you think the parameter
or the argument being bound to it is more important.
Joe Gottman
Suppose I have code that looks like this:
my ($x, $y, $z) = (1, 2, 3);
say "sorted backward" if ++$x > ++$y > ++$z;
Will $z be incremented even though the chained comparison is known to be
false after ++$x and ++$y are compared?
Joe Gottman
odification date is November 16, 2005. Is this the most up-to-date
version?
Joe Gottman
"our"
Note that the third possibility here does not include a return type. Does
this imply that if we want to declare a subroutine with a return type we
have to declare it as either a "my" sub or an "our" sub?
Joe Gottman
#x27;$args as Array" or "Array($args)"
> +%$args; # same as '$args as Hash" or "Hash($args)"
> +&$args; # same as '$args as Code" or "Hash($args)"
Shouldn't this last one be
+&$args; # same as '$args as Code" or "Code($args)"
Joe Gottman
ecutes
> +immediately as in Perl 5. If you wish to return a closure from a
> +function, you must use an explicit C.
> +
How does the "sub" keyword fit in here? Is there any difference between
the lines
return {say "Hello World";};
and
return sub {say "Hello World";};
?
Joe Gottman
ax for the code.
Joe Gottman
is the first big update. There will be more if this all goes well.
I have one minor comment about join. You should specify its behavior when
it is passed an empty list. Does it return undef or the empty string?
Joe Gottman
Is a NEXT clause called before or after the update portion of a general loop
statement? For instance, consider the following code:
loop $n = 0; $n < 5; ++$n {
NEXT {print $n;}
}
Is the output 01234 or 12345?
Joe Gottman
> -Original Message-
> From: Luke Palmer [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 17, 2006 8:44 PM
> To: Perl6 Language List
> Subject: Re: NEXT and the general loop statement
> Wasn't NEXT supposed to do something tricky, such as being mutually
> exclusive with LAST? I remembe
possible? This would require Perl to know which iteration is
going to be the last one. In many cases there is no way to know this:
repeat {
$num = rand;
print $num;
NEXT {print ',';}
LAST {print "\n";}
} while $num < 0.9;
If rand is a true ran
. This would be much easier to implement that the idea of
NEXT blocks being mutually exclusive to LAST blocks, because it depends only
on what happened in the past, not the future. Luke's example could then be
implemented as
for @objs {
.print;
REENTER { print ", " }
LAST { print "\n" }
}
In a language that has both if and unless, it makes sense to have a block
that means not FIRST. I'm not sure about the name; besides REENTER, other
possible names would be SUBSEQUENT or NOTFIRST.
Joe Gottman
first {$_ = $value;} will resume {$_ += value;}
...
}
Joe Gottman
Suppose I have a gather block that spawns several threads, each of which
calls take several times. Obviously, the relative order of items returned
from take in different threads is indeterminate, but is it at least
guaranteed that no object returned from take is lost?
Joe Gottman
Since Perl6 is going to have infix min and max operators, it might be
a good idea to have an infix minmax operator, defined by
$a minmax $b === ($a min $b), ($a max B); #2-element list
This would be especially useful as a reduction operator:
my ($min, $max) = [EMAIL PROTECTED];
Joe
, 11])
Obviously both should be possible, and if we have a multislice with more
than 2 dimensions we should be able to iterate at any level. So what is
the default iteration level and how do we override?
Joe Gottman
Joe Gottman
In the "Multiplicative Precedence" section of S04, "div" is specified twice.
Joe Gottman
Does the interpolating version of qw split a string into words before or
after it interpolates? So if I have
my $foo = 'Hello World';
my @bar = «$foo»;
does @bar equal ('Hello World') or ('Hello', 'World')?
Joe Gottman
taoperator.
Maybe you could use DD instead (for dot product).
Joe Gottman
Apocalypse 4 mentions unary '?' . Since this is used to force boolean
context, I would assume that it has the same precedence as unary '+' and
'_' which force numeric and string context respectively. By the way, has
anyone come up with a use for
',
then gets rid of the bit at the end that we don't want. The capturing
parentheses ensure that we return the part of the string we want, and we
manually reset $pos to the correct position. This is easy to understand,
and very extensible.
Joe Gottman
ot;}
Then you wouldn't even need the BEGIN block.
my declare_var(calc_varname()) = 42;
The compiler wouldn't know the variable name until runtime, but I think this
just means that this just transforms compile-time errors to runtime errors.
Joe Gottman
rns empty string. You could think of C as being
> implemented:
>
> sub join (Str $sep, [EMAIL PROTECTED]) { reduce { $^a ~ $sep ~ $^b } "",
> @list }
>
> Just as C is probably implemented:
>
> sub sum ([EMAIL PROTECTED]) { [+] 0, @list }
>
If this were the case, then
join '~', 'a', 'b', 'c'
would equal '~a~b~c' instead of 'a~b~c'
Joe Gottman
t; (in) Element
> (=) Set equality
>
> I believe the unicode variants are also allowed.
>
> And now we're doing away with junctive types in favor of set types.
Will there be an operator for symmetric difference? I nominate (^).
Joe Gottman
couple of
parameters, one to say how many copies of the list it zips up, and another
to say what the first offset is.
sub contextual($number_of_copies, $first_offset, @list) {...} # I'm not
sure how to write it.
Then your example would be
for contextual(3, -1, create_list_here() )-> $last, $first, $next {
Joe Gottman
There's something wrong with your links to the messages in the
documentation list. Whenever I click on one, I get the message "Unable to
find thread. Please recheck the URL."
Joe Gottman
$var = 2.5;
print "date" if $var == any(1..31);
print "in interval" if 1 <= $var <= 31;
Speaking of which, is there a run-time test to check if a variable is of
integral type? Something like
print "date" if ($var is int) && (1 <= $var <= 31);
Joe Gottman
- Original Message -
From: "Uri Guttman" <[EMAIL PROTECTED]>
To: "Joe Gottman" <[EMAIL PROTECTED]>
Cc: "Perl6" <[EMAIL PROTECTED]>
Sent: Friday, January 03, 2003 10:06 PM
Subject: Re: "my int( 1..31 ) $var" ?
> >>>&
then the first getX would be
called, and if it were called on a non-const Foo object the second one would
be.
Joe Gottman
- Original Message -
From: "Damian Conway" <[EMAIL PROTECTED]>
To: "Perl6" <[EMAIL PROTECTED]>
Sent: Tuesday, March 11, 2003 9:35 PM
Subject: Re: A6: overloading multis on constness of parameters
> Joe Gottman wrote:
>
> >Will it be possi
s scope only if the user returns a reference to it. A static variable
should be like a variable except that it is only initialized once and
is not destroyed when it goes out of scope.
Joe Gottman
no idea how difficult it would be to implement either of these
concepts. Also, if a parameter is deferred, would we need a new keyword to
say when to actually evaluate it?
Joe Gottman
<[EMAIL PROTECTED]> wrote:
> > >
> > >>Dave Whipp wrote:
> > >>
> > >>>Joe Gottman wrote:
> > >
> > >
> > > Getting deep -- sorry. :)
> > >
> > >
> > >>>>Alternatively, t
- Original Message -
From: "Hanson, Rob" <[EMAIL PROTECTED]>
To: "'Rod Adams'" <[EMAIL PROTECTED]>; "Perl 6 Language"
<[EMAIL PROTECTED]>
Sent: Thursday, July 31, 2003 1:29 PM
Subject: RE: Perl 6's for() signature
> > Anyone but me feel the need for non-greedy
> > slurpy arrays? similar
urrence
> can be accessed similarly.
I believe that the OP wanted to know how to match the second-to-last
occurrence. So if we were to do something like
m:nth(-2)/foo/ # just a guess about the syntax.
on a string containing 4 foo's, then this would match the third foo.
Joe Gottman
s copy" attribute, so that it can be modified inside the
loop (by the update portion if nothing else), but does not alias a variable
it was initialized from.
Joe Gottman
e used as a trait on a variable
state $first_iteration will setup {$_ = true} will next {$_ =
false};
Joe Gottman
ns List
Returns the indexes and associated values stored in @array, lazily and in
order by index. Optionally, only those of the slice defined by @indices.
multi sub reduce (Code $expression : [EMAIL PROTECTED]) returns List
{
my $res;
for @values -> $cur {
FIRST {$res = $cur; next;}
$res = &$expression($res, $cur);
}
$res;
}
Joe Gottman
ashed"? That I'd get a warning *any* time I use a
> dash in a character class? I guess I can live with that.
On the other hand, you can use the canonical perl 5 trick of having the
dash be the first character in the class if you want to use a literal dash.
Joe Gottman.
330
> > $ find . -name \*.pl -exec grep -hlE 'qx|`|`|readpipe' {} \; |
wc -l
> > 123
> >
> > `` gets used an awful lot
>
> But that's in Perl 5, which is a glue language.
>
And Perl 6 isn't? I use backticks quite a bit in Perl, and I don't see
that changing if I upgrade to Perl 6.
Joe Gottman
could have another secondary sigil to mark a protected method or
attribute. I'd suggest the semicolon, but I'm afraid it would cause havoc
with the parser.
Joe Gottman
with almost all the changes that people
> here sent me, as well as reading a few more threads and references.
> This will be the last update for some time
The zip operator is now the Yen sign (¥).
Joe Gottman
Now that Apocalypse 12 is out, which one is Larry going to work on next?
Joe Gottman
t this to be defined as a coercion,
> using
> the "as" operator, not "dot":
>
> $foo as boolean
>
> What am I missing?
Why not just use say
?$foo
Isn't the prefix ? operator designed specifically for this use?
Joe Gottman
a statement modifier also? This would be useful for quick
topicalization:
say "$_ => %hash{$_}" given get_random_key();
Joe Gottman
There's something wrong with the mailing list archives at
http://dev.perl.org/perl6/lists/. I can get to this page OK, but when I
click on a link to the perl6-internals or perl6-language archives, I get a
"This page cannot be displayed" error.
Joe Gottman
x27;from' => 2};
Would
splurt :%foo;
have the same result as
splurt :by(1) :from(2);
or would I need the braces in this case?
Joe Gottman
None of the links for the perl6-language threads work.
Joe Gottman
ter all,
in Perl 5, the expression
$string =~ /(a+)(b+)/
returns a list of captured substrings in list context
Joe Gottman
evaluated lazily;
reverse has to see the entire list before it can emit the first element of
the reversed list. Would
@foo = (5 .. 1 :by(-1));
do the trick? If so, would the same trick work for
@bar = ('e' .. 'a' :by(-1)); ?
Joe Gottman
> -Original Message-
> From: Larry Wall [mailto:[EMAIL PROTECTED]
> Sent: Thursday, September 02, 2004 8:41 PM
> To: Perl6
> Subject: Re: Reverse .. operator
>
> On Thu, Sep 02, 2004 at 08:34:22PM -0400, Joe Gottman wrote:
> : Is there similar shorthand to s
imilar.
This would be an absolute necessity if you wanted to emulate C++, Java, or
any other strongly typed language.
Also, it could be useful for causing a compile-time error if someone types
something like
$z = swap($x, $y);
Joe Gottman
s called. It would be nice if there were some way to
curry so that a parameter is bound to a variable reference. This would
probably have to be a different method than assuming. Maybe something like
&printNum(int).bind(x => \$foo)
Joe Gottman
- Original Message -
From: "Luke Palmer" <[EMAIL PROTECTED]>
> Joe Gottman writes:
> > 3) Currying binds a function parameter to a value? Is there any way to
> > bind a function parameter to a variable? Consider the following code:
> >
>
re possible, so they can cascade and nest.
Excuse me. I know enough C++ to know the difference between an lvalue
and an rvalue, but what the heck is a BValue?
Joe Gottman
t; and "invoke" do not.
>
Also, I assume that invoke and check will have access to $a's private
data members and methods, while call will not.
Joe Gottman
ned. In
case 3), the problem is differentiating between an undef returned because
the arrays were of different sizes, and an undef returned because one of the
arrays contained an undef.
Joe Gottman
tle leery about calling this trait "default". The problem is
that we are already using "default" as a keyword (see the switch statement),
and having a trait with the same name as a keyword might confuse users
and/or the compiler.
Joe Gottman
eBark}
{...}
Then we could have code like
my Trog $foo = Trog.new();
my Dog $spot := $foo;
my Tree $willow := $foo;
$spot.bark(); # calls dogBark()
$willow.bark(); #calls treeBark()
This works better when Dog::bark and Tree::bark are both needed but they
do different things.
Joe Gottman
- Original Message -
From: "Luke Palmer" <[EMAIL PROTECTED]>
To: "Joe Gottman" <[EMAIL PROTECTED]>
Cc: "Perl6" <[EMAIL PROTECTED]>
Sent: Tuesday, January 06, 2004 9:34 PM
Subject: [perl] Re: Roles and Mix-ins?
> Joe Gottman writes:
&g
is in loop statements
(formerly for statements), which is where most of them are found anyway.
For instance
loop (my ($x = 0, $y = 10); $x < $y; ++$x, --$y) {...}
Joe Gottman
- Original Message -
From: "Larry Wall" <[EMAIL PROTECTED]>
To: "Perl6" <[EMAIL PROTECTED]>
Sent: Wednesday, January 21, 2004 2:51 PM
Subject: [perl] Re: Comma Operator
> On Tue, Jan 20, 2004 at 08:12:28PM -0800, Jonathan Lang wrote:
> : Joe Gottma
$a >>= 1;
Will this right-shift the value of $a one bit and assign the result to $a
(the current meaning)? Or will it assign the value 1 to each element in the
array referenced by $a (as suggested by the new syntax). Both of these are
perfectly valid operations, and I don't think its acceptable to have the
same syntax mean both. I'm aware that using "Â=" instead of ">>=" will
eliminate the inconsistency, but not everyone has easy access to Unicode
keyboards.
Joe Gottman
sort ('foo', 'bar', 'glarch');
attempt to use the first parameter as a Criteria? Since sort has to be a
multi sub anyhow, why don't we do
multi sub *sort(Criteria $by : [EMAIL PROTECTED]) {...}
multi sub *sort( : [EMAIL PROTECTED]) { ...} # returns sort {$^a cmp $^b} @data
Joe Gottman
> 'a', 10 => 'b', 2 =>'c');
There is nothing in the signature of the key-extractor to suggest that
all the keys are numbers, but as it turns out they all are. Will the sort
end up being numerical or alphabetic?
Joe Gottman
How do you put a literal '{' or '}' into a format string in Perl 6? Do
you use a backslash?
Joe Gottman
lement of @array after we leave the loop; it also ensures
that $prior has the correct value of undef() when we start the loop the next
time.
Joe Gottman
Damian-shaped will probably come in and point out how to prettify
that
> using "given", but it still wouldn't be as short as last week's
>
> $coderef.("argument").{hashelem}.self:sort();
Why not just do
@{$_} = sort @{$_} given $coderef.("argument").{hashelem};
Joe Gottman
gal chaining? Or $x < $y lt $z?
5) Would it be possible for me to create a user-defined operator that
does chaining?
Joe Gottman
e to implement it more efficiently
in the core than as a sub in a module I think we should do so.
Joe Gottman
itialization code is
performed only once. Unfortunately, I have no idea how this would be
implemented in Perl 6.
Joe Gottman
or elsif were usable in
all subsequent elsif or else statements in the same if .. elsif .. else
clause, so you could do something like
if testa() -> $a {say "$a is true"}
elsif testb() -> $b say {"$a is false and $b is true"}
else say {"Neither $a nor $b is true"}
Joe Gottman
=back
Do the results of andthen and orelse really bind to ANY arguments of
the second block? If the second block has two parameters it makes more
sense to me for the results to bind to the first parameter and nothing
to bind to the second parameter.
Joe Gottman
: you might want to mention
the roundrobin function in the article on the zip function since the two
are very closely related.
Joe Gottman
This one's very nice. One question: what's the "~+" operator you
talk about in your discussion of prefix ~ ? I can't find any mention of
it in Synopsis 3.
Joe Gottman
ot be used with , because the
next case might already have been checked when is called.
Joe Gottman
In the definition of cmp, S29 says the function "returns
|Order::Increase|, |Order::Decrease|, or |Order::Same| (which numify to
-1, 0, +1)". Shouldn't the enumerations and their numerical values be
listed in the same order?
Joe Gottman
support.
Yes, they use multiple-typed values such that (3 < 5) returns (5 but
True), which used in a numeric context is a 5 that can be chained with
further infix:{'<'}s but in a boolean context is True.
So does (5 < 3) return (3 but False) or just False ?
Joe Gottman
80 matches
Mail list logo