On Thu, 8 Apr 2010, Carl Mäsak wrote:
Among the cons: we lose the nice symmetry wherein :to clears all
values smaller than days, :to clears all values smaller than
years, etc. :to is still pretty straightforward, but it's a
subtle category error.
Of course. What I really want is for weeks to
Small feature request:
$dt.truncate( :to );
is somewhat ambiguous, since some people start their week on Sunday, while
the module truncates to Monday.
Would you consider a less ambiguous week truncation?
$dt.truncate( :to );
$dt.truncate( :to );
~ John Williams
On Wed, 2 Nov 2005, Michele Dondi wrote:
> On Fri, 28 Oct 2005, John Williams wrote:
> > But IMHO the reduction in typing for this relatively minor issue is not
> > really worth the surprise to newbies at seeing operandless operators.
>
> I don't buy that argument as newb
But IMHO the reduction in typing for this relatively minor issue is not
really worth the surprise to newbies at seeing operandless operators.
~ John Williams
(value) > were allowed at the begining as well as the end of
the parameter list. I think adverbs read better when they are next to the
verbs they modify, and I would be nice if I didn't have to resort to macro
magic to get them there.
Mixing named and positionals is bad though.
~ John Williams
efault
> variable anywhere in the language that isn't $_.
Actually I took his question to be:
If I explicitly name my invocant in the method signature, does that give
the compiler enough assurance that I'm not going to use .method to mean
$?SELF.method, and it will allow me to safely use .method as $_.method in
for and given?
~ John Williams
an install multi subs to coerce them to the type
the user desires. Not sure how well that would work for LOBs.
Or maybe we register a conversion sub with DBI for each database
type we want to be handled specially.
~ John Williams
on subs can optionally be a
pointer to the (section of the POD) document where the documentation
actually resides.
~ John Williams
cation
that you should be using arrays instead of junctions. And I'm not sure
about the object interface to junctions anyway.
> * Is there another way?
Assuming you write the subset coroutine above, how about
$score +=
( subsets(0..4) ==> map { 2 * (15 == [+] @[EMAIL PROTECTED]) } ==> [+] )
~ John Williams
On Thu, 5 May 2005, John Williams wrote:
> or even
>
> @x -= @y;
Doh! That should be C< $x -= $y; > of course.
On Thu, 5 May 2005, David Wheeler wrote:
> > I can see how to ask for a binary (hence infix) operator, but how
> > do I ask
> > for a prefix or postfix operator specifically, which +<< and >>+ do?
> > Maybe there are Operator::Prefix, etc, roles defined so you can ask
> > for
> > them?
>
> Ask for
how to ask for a binary (hence infix) operator, but how do I ask
for a prefix or postfix operator specifically, which +<< and >>+ do?
Maybe there are Operator::Prefix, etc, roles defined so you can ask for
them?
~ John Williams
A06 typo:
>infix:+( prefix:-($a), $b)
>
> [Up
t seems like an idea that should be in a module instead of in
core, which seems like an awful strange thing to say to $Larry.
~ John Williams
P.S. I like [+] better than \\+ because I cannot figure out what \\ would
be mnemonic for.
P.P.S. We can't use (R)+ ... it's already trademarked! :)
;t mentioned in A12.
>
> > I could be wrong, though; I can't find any support for it in the design
> > docs.
"Replicate dimensions" is specified in the first version of A3.
The length issue was resolved on the mailing lists.
Could someone add the ruling to S3 to answer this FAQ?
I believe the fine points fall out like this:
@a >>+<< 1# replicate
@a >>+<< (1) # replicate: (1) is still scalar
@a >>+<< [1] # extend: [1] is an array (and will auto-deref)
~ John Williams
On Tue, 7 Sep 2004, Juerd wrote:
> John Williams skribis 2004-09-07 11:37 (-0600):
> > > and postfix:'th? It's 80s and postfix:th!
> > Probably to help separate the term from the postfix operator.
> >@array[ $foo'th ];
>
> Maybe what I'm s
On Tue, 7 Sep 2004, James Mastros wrote:
> PS -- Unreatedly, why, oh why, do people insist on an apostrophe in 80's
Maybe "in the 80's" is like "at the Jones's". Not that I care, mind you.
> and postfix:'th? It's 80s and postfix:th!
Probably to help separate the term from the postfix operator.
On Sun, 5 Sep 2004, Matt Diephouse wrote:
> Am I the only one that thinks that -1st should return the last element
> in an array under the nth scheme? 1st should mean the first element.
> -1st should mean the first element of the reversed array.
>
> Don't say -1st is the "first from last". If last
because one occurs where an operator is expected, and one occurs where a
term is expected. last (=nth) and last (=break) are both terms
unfortunately.
~ John Williams
On Sat, 4 Sep 2004, Juerd wrote:
> John Williams skribis 2004-09-03 23:06 (-0600):
> > > (A and Z)
> > I think I'd prefer alpha and omega.
>
> Why not use Cyrillic or Korean or the secret code alphabet we used in
> school?
I meant the actual words "alpha"
last but 1 ]
Or does it have to be last but int(1) ?
~ John Williams
> I think we just need something really short and unconfusing for the
> commonest cases,
@a[ 42 ; -1 but last ]
That reads pretty well, no?
Maybe the other end isn't quite as good:
@a[ 1 but first .. -2 but last ]
Hmm. Should "-1 but last" or "0 but last&quo
en that no space is allowed before the
postcircumfix operator? Or does this work:
$foo.ipso 'bar' facto;
Or maybe it has to be declared multi instead of sub for that?
~ John Williams
pe(1..4;1..2); # two dimensions, @ints[1..4; 1..2]
What happens when the Pascal programmer declares
my int @ints is shape(-10..10);
Does it blow up? If not, does @ints[-1] mean the element with index -1
or the last element?
~ John Williams
e block parameter,
which was actually declared as an optional positional parameter
(of type Criteria)?
~ John Williams
On Sat, 14 Aug 2004, Larry Wall wrote:
> To get a Perlish representation of any data value, use the C<.repr>
> method. This will put quotes around strings, square brackets around
> list values, curlies around hash values, etc., such that standard
> Perl could reparse the result. XXX .repr is what
t;"('>$filename', :excl));
while what was actually wanted is written as either of
my $fh = open ">$filename", :excl; # part of the arg list
my $fh = open :excl ">$filename"; # adverb to open
And besides, I think it reads better when the adverb is next to the verb.
yes, no, maybe?
~ John Williams
ot;Hello, Søren!\n"
The string slicing operator would have to return an array of
bytes/codepoints/etc in list context and a substr in scalar context.
~ John Williams
n";
In perl5, this prints:
a
b
Which seems to show that the "my $b" doesn't actually come into scope
until the end of the statement in which it is defined. Is that correct?
and what will perl6 do?
I know an obvious answer is "don't do that", which is what I had to (not)
do, but this is a greatly simplified version of some generated code.
~ John Williams
On Tue, 18 May 2004, Stéphane Payrard wrote:
> I use over and over this idiom in perl5:
>
>$a{$_}++ for @a;
>
In perl6, using a hash slice and a hyper(increment)operator:
[EMAIL PROTECTED];
On Tue, 20 Apr 2004, Juerd wrote:
> Brent 'Dax' Royal-Gordon skribis 2004-04-20 12:58 (-0700):
> > method buffersize()
> > will store {
> > my $sqrt=$^v.sqrt;
> > die "$^v is not a power of two" unless int($sqrt) == $sqrt;
> > $.buffer = "\x[0]" x $^
On Tue, 20 Apr 2004, Brent 'Dax' Royal-Gordon wrote:
> John Williams wrote:
> > I'm not saying there is anything wrong with that, but John Siracusa is
> > asking for something different, I think. A simple accessor which looks
> > like a method without having t
On Tue, 20 Apr 2004, Luke Palmer wrote:
> John Williams writes:
> > On Tue, 20 Apr 2004, Luke Palmer wrote:
> > > There. Now here's the important part: in order to *use* all this, you
> > > import whatever module defines it, and then say:
> > >
>
) is accessor { ... }
}
With this syntax, either method could be simply be omitted to create a
read-only or write-only accessor. The tricky part is getting the trait
on foo($) to override foo() correctly.
~ John Williams
sically, if ` is made a generic bareword quoter, <<>> is its plural
> form. That makes it easier to explain.
<< Well, except that it isn't really! >>
Three different subscripting syntaxes, each with different quoting rules.
I don't find that prospect attractive.
~ John Williams
On Wed, 14 Apr 2004, Juerd wrote:
> I propose to use ` as a simple hash subscriptor, as an alternative to {}
> and <<>>. It would only be useable for \w+ keys or perhaps -?\w+. As
> with methods, a simple "atomic" (term exists only in perlreftut, afaix,
> but I don't know another word to describe a
On Mon, 15 Mar 2004, Larry Wall wrote:
> On Mon, Mar 15, 2004 at 11:56:26AM -0700, John Williams wrote:
> : I'm probably a bit behind on current thinking, but did %hash{bareword}
> : lose the ability to assume the bareword is a constant string?
>
> It's think
$x »+=« ($a, $b, $c, $d);
Or the slightly less attractive (IMHO) syntax invented recently:
$x +=« ($a, $b, $c, $d);
Of course, perl6 will have a built-in reduce function as well (RFC76):
$x = reduce {$^a + $^b} $a, $b, $c, $d;
~ John Williams
tor as a hash subscriptor is
not a "least surprise" to me.
~ John Williams
On Fri, 27 Feb 2004, Luke Palmer wrote:
> John Williams writes:
> > I want to get from here
> >
> > method bar_attr(?$val) is accessor {
> > $.bar_attr = $val if exists $val;
> > return $.bar_attr;
> > }
> >
> I think this is
ve to change the signature in Damian's
example, and I think it will work for $foo.bar_attr -= 999;
method bar_attr(?$rvalue) is accessor {
if exists $rvalue {
croak "Negative value" if $rvalue < 0;
$.bar_attr = $rvalue;
}
return $.bar_attr;
}
Or maybe I'm missing the point completely comments? rebuttals?
~ John Williams
lab uses the term "array" operator, but that may
be overused in perl. Octave says "element by element". Mathematica uses
the term "element-wise". Template Numerical Toolkit used both: "Array
(element-wise)".
~ John Williams
On Mon, 24 Nov 2003, Jonathan Scott Duff wrote:
> or maybe throw some latin in there
>
> while $n++ et @accum < $total { ... }
> while $n++ cum @accum < $total { ... } # maybe?
I think "ac" is the latin conjunction you want.
ac : conj. and, and also, and besides
tax?
I was recently bit by the BLOCK/hashref-EXPR ambiguity here, but maybe
that won't happen as often if hashrefs are required to use => instead of
comma.
~ John Williams
oth be biased by
our personal coding experience on that count. But, no one can stop you
from defining infix:=:= in your own code.
~ John Williams
On Tue, 1 Apr 2003, Michael Lazzaro wrote:
> So I *really* don't think comparing the equality of references will be
> a good idea, in P6. :-)
>
> John Williams wrote:
> > [EMAIL PROTECTED] eq [EMAIL PROTECTED];# true, for the reason I think
> >
uot;value_for_comparison".)
I propose the name "str" for the value_for_comparison method, and "eq" for
the generic comparison operator.
That's how my objects will work, anyway.
~ John Williams
On Tue, 1 Apr 2003, Michael Lazzaro wrote:
> On Tuesday, April 1, 2003, at 10:35 AM, John Williams wrote:
> > On Tue, 1 Apr 2003, Michael Lazzaro wrote:
> >> So I would imagine it _is_ possible to test that two values "have the
> >> same identity", but I
I would imagine it is -not- possible to actually
> get what that identity "is". There's no .id method, per se, unless you
> create one yourself.
What about the \ (reference) operator? If you take two references to an
object, they should compare the same, right?
~ John Williams
On Tue, 11 Mar 2003, Damian Conway wrote:
>
> These are basically all just two edge-cases. Namely:
>
> @var <== LIST
> and:
> LIST ==> @var
>
Have you considered:
LIST ==> @var.operator:=
LIST ==> @var.STOREARRAY
LIST ==> @var.how_do_i_spell_the_assignment_method
?
; }
> + 1;
Well, I think the motivation was that
m/foo/ and do {
something;
}
print "done";
is such a terrible newbie-trap (it was for me, at least), that they had to
do something to fix it.
~ John Williams
What about:
($var &&= 'succeeded') ||= 'failed';
On Mon, 3 Feb 2003, Sean O'Rourke wrote:
> Argh. Please disregard that last message as the ramblings of a
> pre-caffeinated mind.
>
> /s
>
> On Mon, 3 Feb 2003, Sean O'Rourke wrote:
>
> > On Mon, 3 Feb 2003, Dave Mitchell wrote:
> > > $var ??
0[...]. All it needs is $0[1]
> for ordered lookups and $0["1"] for named lookups.
My favorite example of this sort of object is a row from a database.
Each value has a name (the column name) and a position (from the order in
which the columns were requested), so it would be nice
d not be asked
to guess.
Similar precendents are + vs ~, == vs eq, etc.
~ John Williams
bounds)
> > @a[-Inf] # undef (warning: can't use Inf as array index)
>
> Or zero, since it's an int array.
If you throw an exception for +Inf, you should throw it for -Inf too.
~ John Williams
entries for you.
~ John Williams
On Tue, 28 Jan 2003 [EMAIL PROTECTED] wrote:
>
> This may sound like a silly idea but ...
>
> Has anyone considered removing with the syntactic distinction between
> numeric and string indexing -- that is, between array and hash lookup?
>
&g
umeric warning), so it's
definitely choosing to return $a[0] for non-numeric indexes.
(0+"1e" is 1, not 0)
> Is [undef] the same as [0] in Perl6? Is there any index value you can
> give that will cause an exception?
What about @a[NaN]? Just another warning probably.
~ John Williams
On Thu, 9 Jan 2003, Peter Haworth wrote:
> On Wed, 8 Jan 2003 15:39:52 -0500, Dan Sugalski wrote:
> > At 7:29 PM -0700 1/7/03, John Williams wrote:
> > >Perhaps you could explain how the $0 object will work in your mind.
> > >A5 assert that $0 is a object, and it beh
e really easy to do if something like a class invariant
existed which ran _before_ each method...
~ John Williams
rray and a hash,
depending on how you subscript it. Typeglobs are gone, and we're all
hoping the TIE interface is gone too, so how will this effect be
accomplished?
~ John Williams
On Fri, 3 Jan 2003, Dave Whipp wrote:
> John Williams wrote:
>
> > Do they? One is obviously an array, and one is obviously a scalar.
> > You may get an error (cannot alias an array as a scalar) or $b get aliased
> > to the array-in-scalar-context (a reference).
>
>
; or:
> > print "creditcard" if $var.CreditCard ~~ 'VISA';
> >
> I think this is similar to "John Williams" suggestion:
>
> print "creditcard" if CreditCard( $var ) eq 'VISA';
Well, no. In my suggestion, CreditCard i
ty. And
> after
> reading further seeing it could be smart matched like:
>
> print "creditcard" if $var ~~ CreditCard( 'VISA' );
>
> Brought to a point: Properties could be also smart matched.
Wouldn't it be easier to say:
print "creditcard" if CreditCard( $var ) eq 'VISA';
~ John Williams
ng to
work.
On the other, other hand, if the SpecialArray class has defined a
constructor or assignment operator which accepts an Array, then you have
told the compiler how to do the desired autopromotion (although I still
doubt it would work with an alias-operator), and it can mostly DWYM,
although the type of the value has actually changed in this scenario.
~ John Williams
requirements
CON: you already can; don't force it those who don't want it
3) allowing \qq[] in single-quoted here-docs.
PRO: it's consistent with single-quotes
CON: it contradicts the assertion that backslashes are not special in
single quoted here-docs
we need a quoting mechanism where NOTHING is special
(Those are ordered from least to most offensive, BTW.)
~ John Williams
On Thu, 5 Dec 2002, Joseph F. Ryan wrote:
> John Williams wrote:
> >On Thu, 5 Dec 2002, Joseph F. Ryan wrote:
> >>With all of the new crazy quoting shenanagains, I'm not sure that the
> >>"balenced brackets are fine" rule will still be possible; and thus
#x27;ve come close to rejecting it outright simply because the
> single-quoting policy of Perl 5 has been successful.
Maybe if we pushed Larry a bit, he could reject it after all?
Personally I like 'not interpolated'_"interpolated"_'not interpolated'
much better than 'not interpolated\qq[interpolated]not interpolated'.
~ John Williams
pecial, and are taken for a literal backslash, a behaivor that is
> different from normal single-quoted strings. However, \qq[] will
> still work.
That's self-contractidictory: "backslashes are not special" and
"\qq[] is special"
Isn't there any way to say "none of the following characters are special
until I say so" left in perl6?
~ John Williams
"grep" unless you are an aging unix guru...
How about something which is at least obvious to someone who knows what
grep is, such as "vgrep" or "grep:v"?
Or maybe that's not any better than "grep !(...)".
~ John Williams
e that would slow it down.
I don't think the point is to store them as "small" as possible, but as
"efficiently" as possible. That is, in whatever register size the
hardware works best on. We don't want to compact unrelated bits into
a single hardware address, because then we are forced to do extra masking
and shifting everytime we want to use the value.
~ John Williams
On Fri, 1 Nov 2002, Michael Lazzaro wrote:
>... - synonym for ..Inf
Did I miss the report of the bistable ... operator's death?
I've looked around, but I can't seem to find it.
~ John Williams
@a »op« @b # picks the shorter of the two lengths (intersection)
@a «op» @b # picks the longer of the two lengths (union)
Maybe the hyper-hash guys could work with it too.
~ John Williams
ifferent effects out of ^= by virtue of the
"dimensionally replicate, quantitatively undef-extend" rule for vectoring
operators.
@a ^= @b # @a.length == max( @a.length, @b.length )
@a ^= $b # all currently existing elements of @a are set to $b
$b ^= @a # Yuck! $b = last element of @a.
~ John Williams
he postfix can have a space before it?
Or are we introducing this new restriction to perl6 just because someone
can define a binary operator:++ ?
perl5 -le '$a = [[42]]; print $$a [0] [0] ++; print $$a[0][0]'
42
43
~ John Williams
-xor or a vector-one-superposition.
So what if we just made the [] optional? Then all the original
hyper/vector documentation is still valid. (The meanings of ^+ ^|| ^<<=
etc are all non-ambiguous.) For the ambiguous case, ^^ is logical-xor
because it is used more often, and vector-one-superposition is
unambiguously ^[^] .
~ John Williams
On Thu, 31 Oct 2002, Luke Palmer wrote:
> > now *theres* some brackets!
>
> Ooh! Let's use 2AF7 and 2AF8 for qw!
Actually, I wanted to suggest »German quotes« instead of French for qw.
:)
~ John Williams
On Wed, 30 Oct 2002, Me wrote:
> %a ^:union[op] %b
>
> %a :foo[op]:bar %b
I think that any operators over 10 characters should be banished, and
replaced with functions.
~ John Williams
ist" case, as explained here:
<http://archive.develooper.com/perl6-language%40perl.org/msg10961.html>
($a = 0) [+=] @b; # sum
($a = 1) [*=] @b; # product
($a ='') [~=] @b; # cat
~ John Williams
sed.
I agree. b| and b& are the first operators which look good to me. Most
of the other proposals look like line-noise, and I would hate to have to
start agreeing with perl-detractors. Bitand and and bitor work for me
too.
~ John Williams
On Sat, 12 Oct 2002, Larry Wall wrote:
> On Sat, 5 Oct 2002, John Williams wrote:
> : Personally, I hope they look like attributes.
>
> They will, outside the class anyway. Inside it's $.foo.
>
> : But if they do, the perl5
> : lvalue subs are not the way to do it. W
Recipe 1.15
I think the thought here was to use the binding operator.
my ClassAlias := MyClass;
~ John Williams
2 is a bit counter-intuitive mathematically. I'm not sure
what the intuitive behavior should be for the other unary operators
though.
I can post a revised table if the associativity of 'but' is clarified.
~ John Williams
my $zen = true but false;
t's like saying
$y = @ARGS[$_] for 0..+@ARGS;
so $y will probably end up with the _last_ element of @ARGS.
I suggest:
my $y = shift; # if this still works in perl6
my $y = @ARGS[0];
~ John Williams
lvalue subs are not the way to do it. Why? Because an lvalue sub returns
a lvalue which get set _after_ the sub returns. At that point it is too
late for the sub to do anything useful with the new value.
~ John Williams
o gets called first when something has
multiple properties.
A think a lot of the syntax discussions could be narrowed down better if
we had some inkling of the implementations.
(Since properties are completely new in perl6, which apocalypse do they
belong to anyway?)
~ John Williams
On Fri, 4 Oct 2002, [EMAIL PROTECTED] wrote:
>
> Perhaps to go with Apocalypses and Exegeses we could have Psalms, a bunch
> of bitsize perls of wisdom. Except, um, psalms are, by definition, sacred,
> so, um, I dunno, just a thought. Larry?
Proverbs?
> which define a "Node" class?
Hopefully, LinkedList defines a LinkedList::Node class, and BTree defines
a BTree::Node class. Either by explicitly naming them that or by virtue
of being defined as an "inner" class (which might also make it private).
~ John Williams
ely
clear. Maybe in (5 but false + 3) the false property is combined with the
boolean conversion of 3 (true). Or undef if the conversion is not
possible. Or maybe I'm rambling on too long...
~ John Williams
t_ solve the problem?
Finally, a question about interfaces:
In what way is an interface different from a pure abstract class (i.e.
containing only method declarations, but no code)?
~ John Williams
DISCLAIMER: This post assumes perl6 will have multiple inheritance.
nd 'but' with high precedence(?)
my $thing is constant = 3 but false;# higher than =
Larry mentions that other precedence unifications are possible. I can see
the following as possibilites. Are there others?
& with &&
| with ||
<< >> with * /
~ John Williams
perators will define their behavior.
Otherwise, a contextualized undef (0 in numeric context, '' in string)
would seem DWIM to me.
I wouldn't want to throw tons of warnings from one operation, so maybe
hyper-operating on unequal lengths gets a new warning, instead of throwing
lots of 'undefined value' warnings.
~ John Williams
and binary operators, including those that are
user-defined. If the two arguments are of different lengths, the operator
Does What You Mean (which, depending on the operator, might involve
padding with ones, zeroes or undef's, or throwing an exception)."
~ John Williams
t flattens, what doesn't, and how do you override the behavior?
Is there anything I missed?
~ John Williams
(1,2,3), [1,2,3];
>
> Behaves in ways that will take hours to explain to newbies, and I assure
> you it ain't WIM. Not even a little bit.
The parenthesis have no effect because they are only grouping. So the
only question in my mind is whether @y gets flattened or is treated as a
single object. In either case, we can clarify our meaning by writing *@y
to force flattening or \@y to prevent flattening.
~ John Williams
Your post was very helpful to pull us back to sanity.
Allowing list context to create a 1-item list out of a scalar makes sense
in my mind. (ie @a = 7 sets @a[0] to 7).
~ John Williams
P.S. Caution: this way lies madness...
In perl5, to get the 'x' repetition operator to do a l
r as the perl5 s/// return value. (Actually s///
returns "" on no matches now, whereas $0 would evaluate to false or 0
depending on context, but I doubt that would be a serious compatibility
issue.)
And getting the matching values before substition was done is a bonus in
list context.
~ John Williams
ce the comma!
)
Of course, _requiring_ the comma is bad, but as long as we can use [7] or
rely on list context creating a single item list out of a single item, it
is not required.
~ John Williams
On 21 Sep 2002, Smylers wrote:
>
> Does that matter? This example is fairly contrived, and anybody
> actually concerned about this can always use:
>
> $num = @massive.length;
>
> So perhaps this isn't a problem.
$num = +@massive;
would also set $num to the le
) exists). +(7) could
still be the length of a list.
Of course there are non-numeric contexts too, such as ("a"). Would it be
fair to say that parenthesis should not alter the context when used in
expressions?
~ John Williams
# boolean (same as (7).length == 1)
No, that last one is clearly numeric context. == operates on numbers and
returns boolean. I can't tell whether (7).length is asking for the length
of 7 or the length of a list, but I would be badly surprised if
(3+4).pow(2) returned 1 instead of 49.
~ John Williams
On Fri, 20 Sep 2002, Tanton Gibbs wrote:
> > I believe the last two cases should be:
> >
> > (7,)== 1
> > (,) == 0
> >
> > Because its the perl6 comma that creates the list, not the parenthesis.
> >
> > ~ John Williams
>
>
1 - 100 of 104 matches
Mail list logo