Does Perl need a no-op function?
With the addition of "no bare literals", it makes constructs like
1 while some_func();
an error. I propose creating a no-op function "nothing" that can be used
here or anywhere else you specifically wish to do nothing at all.
given
the value in a void context, and we could suppress that warning for
0 and 1 like we do Perl 5 without violating our "no barewords" dictum.
: I propose creating a no-op function "nothing" that can be used
: here or anywhere else you specifically wish to do nothing at all.
:
:
Larry Wall wrote:
On Sun, Mar 20, 2005 at 09:08:08PM -0600, Rod Adams wrote:
: I propose creating a no-op function "nothing" that can be used
: here or anywhere else you specifically wish to do nothing at all.
:
: given $this {
:when Even { nothing };
:when Prime { ... };
:
Rod Adams skribis 2005-03-21 14:25 (-0600):
> if $expr {
> nothing;
> }
> is harder to get confused over, IMO
Except writing something when you mean nothing is kind of weird. It
makes sense in rules because it doesn't usually make sense to match
nothingness, but for bl
Juerd wrote:
Rod Adams skribis 2005-03-21 14:25 (-0600):
if $expr {
nothing;
}
is harder to get confused over, IMO
Except writing something when you mean nothing is kind of weird. It
makes sense in rules because it doesn't usually make sense to match
nothingness, but for blocks
Austin Hastings skribis 2005-03-21 15:55 (-0500):
> I'd like to see nothing as just an alias for {}.
> if $expr
> {
>do nothing;
> }
> Possibly the most clear piece of P6 code ever.
Dangerous, though :)
do nothing if $input =~ /\W/;
system "rm -- $input
Juerd wrote:
Austin Hastings skribis 2005-03-21 15:55 (-0500):
I'd like to see nothing as just an alias for {}.
if $expr
{
do nothing;
}
Possibly the most clear piece of P6 code ever.
Dangerous, though :)
do nothing if $input =~ /\W/;
system "rm -- $input";
Bu
In the following code fragment, what context is foo() in?
@ary[0] = foo()
the following code
@ary= foo()
obviously evaluates @foo in a list context, but in the first I'm no
longer sure.
--
Piers
"It is a truth universally acknowledged that a language in
possession of a ri
To take the E6 example of currying &part:
&List::Part::part.assuming(labels => <>)
One had to curry in C to be the same as it was defined in C<&part>
originally, i.e. C<< <> >>.
What if one wanted to curry in whatever the default is, i.e., assumin
Thus it was written in the epistle of Piers Cawley,
> In the following code fragment, what context is foo() in?
>
> @ary[0] = foo()
Scalar, I would think.
Just my guess,
Ted
--
Ted Ashton ([EMAIL PROTECTED]) | From the Tom Swifty collection:
Southern Adventist University| "Multiplicati
On Thu, Dec 13, 2001 at 12:12:14PM -0500, Ted Ashton wrote:
> Thus it was written in the epistle of Piers Cawley,
> > In the following code fragment, what context is foo() in?
> >
> > @ary[0] = foo()
>
> Scalar, I would think.
I assume that the following would make the assignment a slice
an
ll next to mine's.)
--Brent Dax
[EMAIL PROTECTED]
Configure pumpking for Perl 6
"Nothing important happened today."
--George III of England's diary entry for 4-Jul-1776
> In the following code fragment, what context is foo() in?
>
> @ary[0] = foo()
Scalar context. @ary[0] is a single element of @ary.
To call foo() in list context use any of the following:
(@ary[0]) = foo(); # Assign @ary[0] the first element returned
@(@ary[
On Thu, 13 Dec 2001 12:17:44 -0500, Mark J. Reed wrote:
> @i = (0);
> @ary[@i] = foo();
>
>How could one get that behavior without the intermediate array?
Parens, likely.
(@ary[0]) = foo();
--
Bart.
On Fri, Dec 14, 2001 at 06:39:02AM +1100, Damian Conway wrote:
>
>> In the following code fragment, what context is foo() in?
>>
>> @ary[0] = foo()
>
> Scalar context. @ary[0] is a single element of @ary.
>
> To call foo() in list context use any of the following:
>
> (@
> > @ary[0] =()= foo(); # " " " " " "" "
>
> Hm, thats a change from perl5. In perl5 that would assign the number of
> elements returned from foo(). Is there a good reason for this change ?
Firstly, Larry may have to rule on which behaviour actually *is*
"Brent Dax" <[EMAIL PROTECTED]> writes:
> Piers Cawley:
> # In the following code fragment, what context is foo() in?
> #
> # @ary[0] = foo()
>
> The short answer is scalar context. The long answer is below. Note
> that the long answer is only the way I think of it. You may think
> differe
Piers posed the following puzzles:
> @ary[0] = foo() # scalar
Yes.
> @ary[1,2] = foo() # list context
Yes.
> @bar = 1;
> @ary[@bar] = foo() # ? probably list or maybe scalar...
List. With an explicit array as index, it's definitely a (one-element) slice.
> @bar = (1,
On Sun, Dec 16, 2001 at 03:55:10PM +1100, Damian Conway wrote:
[...]
>> And, just for laughs:
>>
>> $ref = [1,2];
>> @ary[$ref] = foo(); # probably a syntax error
Ok, as far as I can recall, Larry hinted that arrays and references to
arrays would be interchangable in many
Aaron Sherman <[EMAIL PROTECTED]> writes:
> On Sun, Dec 16, 2001 at 03:55:10PM +1100, Damian Conway wrote:
>
> [...]
>
>>> And, just for laughs:
>>>
>>> $ref = [1,2];
>>> @ary[$ref] = foo(); # probably a syntax error
>
> Ok, as far as I can recall, Larry hinted that arrays a
> > $val = (foo())[0];
> >
> > List?
>
> Scalar, obviously.
How do you figure that? (Not a criticism: I'd really like to understand your
thought process here so I can assess the relative DWIMity of the two
alternatives).
> With a possible runtime error if foo doesn't ret
Aaron Sherman wrote:
> >> $ref = [1,2];
> >> @ary[$ref] = foo(); # probably a syntax error
>
> Ok, as far as I can recall, Larry hinted that arrays and references to
> arrays would be interchangable in many contexts in P6. In this case, I
> can't see any reason that subscripting wou
Damian Conway <[EMAIL PROTECTED]> writes:
>> >$val = (foo())[0];
>> >
>> > List?
>>
>> Scalar, obviously.
>
> How do you figure that? (Not a criticism: I'd really like to understand your
> thought process here so I can assess the relative DWIMity of the two
> alternat
Resending due to BT doing bad things to good nameservers.
Damian Conway <[EMAIL PROTECTED]> writes:
>> >$val = (foo())[0];
>> >
>> > List?
>>
>> Scalar, obviously.
>
> How do you figure that? (Not a criticism: I'd really like to understand your
> thought process her
;> >>.
>
> What if one wanted to curry in whatever the default is, i.e.,
> assuming
> "nothing" (different from "assuming nothing"), so that if
> List::Part::part
> changed its default for C to C<< <> >>, the
> client
> c
In a message dated Thu, 31 Jul 2003, Austin Hastings writes:
> assuming(labels => undef)
Okay... I think you're wrong, because this would have to be a special case
(defaults take effect only when *nothing* is passed in, not when the
argument is undefined) but, assuming you're ri
:
> In a message dated Thu, 31 Jul 2003, Austin Hastings writes:
> > assuming(labels => undef)
>
> Okay... I think you're wrong, because this would have to be a special
> case
> (defaults take effect only when *nothing* is passed in, not when the
> argument is un
Trey asked:
To take the E6 example of currying &part:
&List::Part::part.assuming(labels => <>)
One had to curry in C to be the same as it was defined in C<&part>
originally, i.e. C<< <> >>.
What if one wanted to curry in whatever the default
<> >>.
> >
> > What if one wanted to curry in whatever the default is, i.e., assuming
> > "nothing" (different from "assuming nothing"), so that if List::Part::part
> > changed its default for C to C<< <> >>, the client
> >
efined in C<&part>
> > > originally, i.e. C<< <> >>.
> > >
> > > What if one wanted to curry in whatever the default is, i.e., assuming
> > > "nothing" (different from "assuming nothing"), so that if List::Part::part
Luke Palmer <[EMAIL PROTECTED]> writes:
> A synonym of:
>
> delete %h{foo};
>
> would be
>
> %h{foo} = nonex;
This has the potential, if not documented exactly right, to create
bogus expectations. Consider...
$s = %h{foo} = nonex;
After deleting the foo key (and its value, if any)
Jonadab the Unsightly One said:
> $s = %h{foo} = nonex;
>
> After deleting the foo key (and its value, if any) from %h this then
> probably procedes to autovivify it when evaluating it as an rvalue;
Now why on earth would you want to do that? Perl 5 doesn't.
By the way, I trust this will be
On Mon, Sep 08, 2003 at 11:18:12AM +0200, Paul Johnson wrote:
: By the way, I trust this will be addressed (if it hasn't been already):
:
: perl5 -le 'print "gah!" if exists $a{b}{c}; print "phooey!" if exists $a{b}'
:
: perlfunc says:
:
: This surprising autovivification in what does not at f
--- Larry Wall <[EMAIL PROTECTED]> wrote:
> On Mon, Sep 08, 2003 at 11:18:12AM +0200, Paul Johnson wrote:
> : By the way, I trust this will be addressed (if it hasn't been
> : already):
> :
> : perl5 -le 'print "gah!" if exists $a{b}{c}; print "phooey!"
> : if exists $a{b}'
> :
> : perlfunc say
Since afaict this is not specced, I'll hand that over to p6l.
Eric Hodges (via RT) wrote:
> use v6;
>
> rule test {test};
>
> "test" ~~ //;
> say '$/.keys => ', $/.keys.perl;
> say '%($/).keys => ', %($/).keys.perl;
>
> # outputs
> # $/.keys => []
> # %($/).keys => ["test"]
>
>
> Same could be
Moritz Lenz wrote:
> Since afaict this is not specced, I'll hand that over to p6l.
>
> Eric Hodges (via RT) wrote:
>> use v6;
>>
>> rule test {test};
>>
>> "test" ~~ //;
>> say '$/.keys => ', $/.keys.perl;
>> say '%($/).keys => ', %($/).keys.perl;
>>
>> # outputs
>> # $/.keys => []
>> # %($/).keys
How do you declare a function that doesn't return anything? For instance, a
C++ swap function might be declared
template
void swap(X &x, X &y);
It would be nice to declare the corresponding Perl6 function as
sub swap ($x is rw, $y is rw) returns nothing {...}
or something s
Joe Gottman writes:
> How do you declare a function that doesn't return anything? For instance, a
> C++ swap function might be declared
>template
> void swap(X &x, X &y);
>
> It would be nice to declare the corresponding Perl6 function as
> sub swap ($
> "given nothing...":
>
> given () { ... }
do { ... }
seems simpler.
> Suppose you want to preserve $_ and alias
>
>given $value -> $g {
'->' seems more visually noisy than it need be in this case.
Perhaps:
given $value as $g
Me wrote:
> > "given nothing...":
> >
> > given () { ... }
>
> do { ... }
>
> seems simpler.
But doesn't have the same effect. A C inside a C responds to
the current value of the "subject" specified by any surrounding
topica
def" in most code is
considered bad style--then we can steal them for the language's
purposes, such as passing to a for block as lookbehind and lookahead
parameters when you're near the beginning or end of a list.
It seems like I'm making a pretty big deal out of just passing undef
w
-glossary.pod
Log Message:
---
[S99] associativity's got nothing to do with it :)
Commit: 793babac4bf1316f787b2a08403bb7b1ca6b072c
https://github.com/perl6/specs/commit/793babac4bf1316f787b2a08403bb7b1ca6b072c
Author: Carl Masak
Date: 2013-07-01 (Mon, 01 Jul
On Thu, Sep 29, 2005 at 11:21:20PM -0600, Luke Palmer wrote:
[ discussion on undefs elided ]
Since we can annotate our undefs now, perhaps undefs that would be
generated because there are no previous or next elements get "tagged"
as such. Something like:
# assuming $b and $a are "before"
43 matches
Mail list logo