Simon Cozens wrote:
It may take a *couple* of nights, but the elves will be at work.
Bless their pointy little hats/ears/beards/shoes! ;-)
Damian
Mark A. Biggar wrote:
Expect wouldn't that produce a extra blank line if $text is short?
Nope. Formats only generate text lines if at least one of their fields
interpolates at least one character.
Damian
d displaying a number with more accuracy
than it actually possesses ...
should probably be "precision" instead (the degree of granularity to
which a number is specified, rather than how 'truthful' the number
is).
I deliberately avoided "precision" since it's not quite the right word either
in this situation.
Damian
Mark A. Biggar wrote:
What if I want to interpolate an empty string and let the fill
characters work?
Then you interpolate a single fill character instead of the empty string.
Damian
Joe Gottman asked:
How do you put a literal '{' or '}' into a format string in Perl 6? Do
you use a backslash?
Yes, a backslash will quote anything (including backslash).
Note that you really only need to backslash '{', since '}' isn't special by
itself.
Damian
* disappear.
After all, you wouldn't expect:
$str1 = "nothing" . "to" . "see";
to be different from:
$str1 = "nothing" . "" . "to" . "" . "see";
Damian
Would that need to be a double backslash in a double-quoted string, or
is there some new Perl 6 magic that keep it from being needed?
No, it would need to be a double backslash in a qq{..} string.
Fortunately qq{..} strings are very rarely needed in Cs.
Damian
TED];
print "\n";
print map {form "| {[[[} |", $_} @data;
Damian
I wrote:
[Perl6::Slurp] will most likely appear in the next 36 hours.
It's now on the CPAN.
Damian
ing kept up-to-date?
Apparently not. Though I can certainly see where Marcel might prefer not to
include the more...err..."exploratory" Perl6:: modules, since he'd have to be
rereleasing the bundle far too often.
Damian
don't need to approach OO Perl with a
different mindset, after a while you're
almost certain to discover one. I don't know
of any other programming language that can
give you that.
Damian
Problem solved!!! ;-)
Damian
(Seriously though, full justification
is mainly there for completeness, and
in readiness for the day when C
is able to handle variable-width text
and/or HTML output. In the interim we
just aim to produce the most readable
results given the constraints imposed
quot;/;
return $_;
}
use Form :field{ /\[.*?\]/ => &translate,
/\{ <[][I"]>+ \}/ => { die "Ugly field: $^yuck" },
};
sub form is exported {...}
}
Or, in Perl 5:
package Perl6::Form::Less::Travailed;
sub translate {
for (shift) {
s/^\[/{/;
s/\]$/}/;
tr/<>|'/[]I"/;
return $_;
}
}
use Perl6::Form {
field => { qr/\[ .*? \]/x => \&translate,
qr/\{ [][I"]+ \}/x => sub { die "Ugly field: $_[0]" }
},
};
use Perl6::Export;
sub form is exported;
1;
Damian
g & to rules.
Indeed, if Larry were to give the word, I'd be delighted to add support for it
to the Perl6::Rules module.
Damian
Larry wrote:
: Indeed, if Larry were to give the word, I'd be delighted to add support for
: it to the Perl6::Rules module.
Execute! (I hope that's the right word...)
I believe, Captain, the correct word would be: "Engage!"
Data^H^Hmian
a UNITEND as well?
Damian
are
guaranteed to run before any main CHECK, we might want a UNITEND that's
guaranteed to execute before any main END.
Damian
Luke Palmer wrote:
Hooray! That was something I had been worried about.
But C doesn't seem to fit visually. What's "questionable" about
that?
Nothing questionable, but
everything hypothetical:
captures to the
$?foo hypothetical variable
Damian
variable:
/ $foo:=(abc) $bar:=(def) /
And since subrules that capture always capture to hypotheticals, we need the
same marker there.
Damian
arily-hypothesized variables ($foo, $bar, @baz).
The syntax we've chosen to do that requires the use of "?" as a secondary
sigil on internal variables. So, since named subrules that capture always
capture to internal variables, it's natural and consistent to use "?" to
indicate capturing subrules as well.
Damian
cond is actually *more* likely to be
(small-l) laziness than error.
There are also cases where something like:
$a ||= $b;
or:
$a += $b;
changes the type of value in $a. Should we flag those too? Currently we do
warn on the second one if $a can't be cleanly coerced to numeric. Would that
be enough for C too, perhaps?
Damian
, under CNF semantics, that's what we get:
1|4 == 1&4
= ((1|4) == 1) & ((1|4) == 4))
= (1|0) & (0|1)
= 1
But, under DNF semantics that would be:
1|4 == 1&4
= (1 == (1&4)) | (4 == (1&4))
= (1&0) | (0&1)
= 0
Which is wrong.
Which, again, is why we use CNF.
Damian
aQ" not "pitaph".
Hey...wait a minute!
petaQ chopong?
bIQambogh DaqDaq qaHoH!!
{{;-)
Damian
you were you stand!!
;-)
BTW, how did you generate that Â, or did you mouse it?
I mapped one of my iBook's function keys to it.
Damian
de to implement Simon's 12 distinct boolean
values.
However I do think that, now we have C to carry the load of "exists
uniquely", Larry will probably decide that C is strictly binary, and
hence generalizes to the "parity" form in the n-ary case. I just don't want
people to think we neglected to consider the other valid alternatives.
Damian
wing off. All you really need is:
if ( specific_condition() ? detail() : general_condition() )
{
act();
}
;-)
Damian
(Just not where you might have expected ;-)
Damian
accessor ($attr{type} $attr{$attr_var}) {} "
~ "method get_$accessor () { return $attr{attr_var} } "
~ "has $attr{type} $attr{attr_var}"
;
}
and then:
class Dog {
use GetSet;
getset $.name;
...
}
Damian
Right...in Perl 5.
In Perl 6, a hash in a numeric context returns the number of entries it
contains. So I can readily imagine:
sub decimate_hash (%hash is rw) {
for 1..%hash/10 {
delete %hash{ pick any(keys %hash) };
}
}
Damian
error!
No.
foo(1, 2); # compile-time error!
Yes.
foo(a => 1, 2); # compile-time error!
Yes.
foo(a => 1);# compile-time error!
No.
foo(a => 5, b => 7); # ok
foo(b => 1, a => 2); # ok
Yes. Yes.
You want:
sub foo(+$a is required, +$b is required) { ... }
Damian
-export them as their own.
My proposal for that issue is just:
module Bar;
use Foo «foo»;
sub foo is export {...}
This works perfectly in Perl 5 under the Perl6::Export module (now on the CPAN):
package Bar;
use Perl6::Export;
use Foo qw(foo);
sub foo is export;
Damian
Larry wrote:
On Sat, Apr 24, 2004 at 09:52:12AM +1000, Damian Conway wrote:
: My proposal for that issue is just:
:
: module Bar;
:
: use Foo «foo»;
:
: sub foo is export {...}
That's on the right track, but has some difficulties, insofar as it's
not clear that the intent is t
certain to change as a result of this very thread).
Damian
Austin Hastings wrote:
Hmm. For junctions I was thinking:
++ all([EMAIL PROTECTED]);
Which is almost readable.
But unfortunately not correct. Junctions are value, not lvalues.
This situation is exactly what hyperoperators are for:
++Â [EMAIL PROTECTED];
Damian
Luke asked:
Er, did the hyper operator's direction flip? I thought it was:
++Â [EMAIL PROTECTED];
My bad. 'Tis indeed.
Damian
avoid introducing new features that encourage new mistakes.
Damian
Scott wrote:
I'm just waiting for Damian to speak up :-)
I'm not at all comfortable with the notion of junctions as lvalues.
I've *always* considered a junction to be a special kind of constant, just as
a number or a string or a reference is.
I have trouble with junctive lvalues
}
So what about:
$foo[$i]
$foo{$k}
???
And would slices interpolate?
I can't say I'm keen on making {...} special in strings. I felt that the
$(...) and @(...) were a much cleaner and more general solution. The prospect
of backslashing every opening brace in every interpolated string is not one I
relish.
Damian
drive {
given .vehicle {
when Truck { goto &SanitationEngineer::drive }
default { goto &RaceCar::drive }
}
}
};
Damian
ity for totally nuking them?
macro PRE (&block) {""}
macro POST(&block) {""}
Damian
ree of
submatches (including whitespace and comments, if you want them), which you
can then reprocess as you wish.
Damian
PS: Yes, I'll be at OSDC next week (giving the opening and
closing keynotes, in fact). And, yes, you're most welcome have a chat with
me about Perl 6 sometime during the conference.
ly defined fairly broadly).
And Perl 6's C will be able to give you the same.
In any case, I would like to suspend this debate for a week, as I'll be
talking with Damian (hopefully) at YAPC.AU. I'll report back afterwards,
having hopefully imparted the full extent of my problem.
I b
tic lexability you
end up with a language with all the nuanced expressive power and syntactic
flexibility of, say, Pascal or Java. :-(
Damian
ou wanted to get a function for each element in an array @a, I
suppose you can say:
sub makefunc($x){{$x}}
@funcarray = @a>>.makefunc;
You're attempting to call a sub as a method. You want:
@funcarray = »makefunc« @a;
Damian
t you just *love* that in
the guy who's job it is to actually make this stuff work! ;-)
Damian
x.none {...}
Probably. It's entirely possible that, in addition to being built-in list
operators, C, C, C, and C are also multimethods on
Scalar, Array, and List.
Damian
ence of the
autothreading of a junction, is indeterminate.
Damian
unction
(did you mean $x.values(), or $x.perl(), or $x.pick() ???)
Damian
nique values seems easy enough
@xyz = all(@xyz).values();# remove any duplicate elements of @xyz
BTW, I'm pretty sure there will be built-in C and C
methods in Perl 6. So that's just:
@xyz = uniq @xyz;
or better still:
@xyz.=uniq;
Damian
select at random from a list, array, or hash
I'm sure there are many others.
Damian
ide-effects is autothreaded:
use warnings 'autothreading';
Damian
if they don't.
use warnings 'autothreading';
This works for me but I'd make it one of the default set of enabled
warnings from a plain "use warnings;" though.
I expect it might be.
Damian
n this list:
http://www.nntp.perl.org/group/perl.perl6.language/13400
Damian
Yes. The function is called C. See:
http://search.cpan.org/~dconway/Perl6-Slurp-0.03/Slurp.pm
Damian
David Storrs OOC'd:
OOC, will there be a way to control where C gets its randomness
from? (e.g. perl's builtin PRNG, /dev/random, egd, etc)
Sure:
# Use RBR (Really Bad Randomness) algorithm...
temp *rand (Num ?$max = 1) {
return $max/2;
}
my $guess = @data.pick;
Damian
, Set $b){ set($a & $b) }
multi sub infix:<-> (Set $a, Set $b){ set( $a & none($b) ) }
multi sub prefix:<-> (Set $a) { set(none($b) ) }
multi sub infix:«<=» (Set $a, Set $b) { true all($a.values) ~~ $b }
multi sub infix:«>=» (Set $a, Set $b) { true $a ~~ all($b.values) }
}
Damian
.
one($a,$a,$b) == ($a == $b ?? undef :: $b)
True.
Damian
n) in which
it's used.
So if:
$x = -1 | 11;
then:
10 < $x < 0
--> any(10 < -1 < 0, 10 < 11 < 0)
--> any(10 < -1 && -1 < 0, 10 < 11 && 11 < 0)
--> any(false, false)
The mistake is in thinking that the n-ary comparison should be expanded before
the junction autothreads.
Damian
Jonathan Scott Duff wrote:
none($a, $a) == undef
True.
Isn't this one false in the case when $a is undef?
Yes. Apologies for not being more precise.
Damian
none($a,$b)==$d,
)
-> none(
0,
0,
1,
1,
)
-> false
Damian
s and operators).
Apologies all...and thanks Patrick.
Damian
any( $ref.meth1(10) + -1, $ref.meth1(10) + 10 ) )
Definitely the latter. As Einstein avowed: "no spooky action at a distance!"
;-)
Damian
rijus's work both amazing and amazingly useful: as a way of
exploring the deeper design and implementation issues, and also as a way for
people to start playing with (and experiencing the real power of) Perl 6.
Well done, Autrijus!
Damian
ass XML is Language {
method serialize($data) {
...
}
}
# etc.
Damian
2-ary &*coerce:as
2-ary &*coerce:as
# etc.
or (more likely, given the dynamic nature of Perl) a single entry that's a
"trampoline" that instantiates particular parameterizations of the generic
class as they're needed:
2-ary &*coerce:as
Damian
ead. And we'll happily
give you a C pragma so you can be emphatic about not wanting them.
But bowdlerizing the concept of junctions isn't the answer.
Damian
k into the discussion.
Damian
# At the top of the program...
no junctions 'assignment'; # Junctive constants okay
# and then...
if is_prime(any(@x)) {...} # Explicitly threaded
or, even more thread-explicitly:
# At the top of the program...
no junctions 'assignment'; # Junctive constants okay
# and then...
if any is_prime«(@x) {...} # Explicitly threaded
Damian
y implicit threading.
Damian
~<< ~>>
additive+ - ~ +| +^ ~| ~^
Damian
l. For example:
sort 1|10, 5|6, 11|0
in which *any* permutation of the list is a plausible sort. So sorting
junctions isn't necessarily always meaningful.
Damian
but I'm afraid I have to bow out of it
now.
Damian
PS: FWIW, I'd have absolutely no objection to us adding a fifth core
junctive type (perhaps C, perhaps just C ;-) that
has *no* associated predicate, but which implements full set semantics:
my $x = set(1..3);
Nicholas Clark wrote:
On Sun, Feb 20, 2005 at 07:41:16PM +1100, Damian Conway wrote:
Given this:
my $x = set(1..3);
my $y = set(1,3,5,7,9);
my $n = 2;
$x | $y # set(1,2,3,5,7,9)
$x & $y # set(1,3)
$x - $y # set(2)
ingified if it's a valid
identifier, but both the key and the value can be any kind of Perl data
structure. They are accessed via the pair object's C and C
methods...
Damian
t C.
> In pugs, currently it's ordered by local vs global, then by subtyping
> distance of invocants, then finally by then finally by the order of
> creation of CODE objects. That's just a working heuristics, though.
The dispatch resolution process is described in A12, under "Calling via
Multiple Dispatch". It's close to what you describe above, except the
"local vs global" distinction is a little more complex, and the
final discrimination is via C, not via C object
creation sequence.
Damian
ngs. The Prime Junction Rule was the big
> revelation I had the other night. The rest of this was the logical
> consequence spawned off that single thought to make it a complete idea.
>
> I think that overall in this process I've done the following:
> - Kept the real power of Junctions intact.
> - Provided fairly strong protection for newbies, without sacrificing
> power.
> - Kept Nasty surprises to a minimum.
> - Got rid of the need for "half on" features.
> - Provided back any power that the Prime Rule removed through sets and
> expanded hyper ops.
Leaving aside the Unnecessary Restriction on junctions (a.k.a. Prime Rule ;-),
the main downside is that we would be multiplying our entities.
We'd need to be certain that the increased cognitive load is worth
the benefits.
Damian
@b[2]),
foo(@a[1], @b[0]),
foo(@a[1], @b[1]),
foo(@a[1], @b[2]),
foo(@a[2], @b[0]),
foo(@a[2], @b[1]),
foo(@a[2], @b[2]);
Yeah, that was the bit that nearly has me convinced. ;-)
Damian
atal error on ambiguity, then.
But only if there isn't a variant marked C.
Damian
Aldo Calpini wrote:
Damian Conway wrote:
>@s = 'item' _ [EMAIL PROTECTED];
That's:
@s = 'item »_« @x;
(just checking that my unerstanding is correct, don't want to be
nitpicking :-)
assuming that you meant to prepend the string "item" to each
junctions.
Without it, you're free to ignore that predicate
Yep.
If you're ignoring the predicate, a junction is just a list of values.
No. You can ignore the predicate because you don't need it *yet*.
Treat it as such. A list. Hyperquotes will deal with those situations
nicely, th
bread-winning must, for the moment, take precedence over most of my
public activities).
Damian
-cut--cut--cut--cut--cut-
There would be a single consistent rule that says that every POD block
(except raw text blocks) has one of the following three equivalen
dear!
=ray -- A ravening beam of destruction
=me -- A name I call my invocant
=far -- A long, long way to Australia
=sew -- What I do with contention
=LA -- A place to follow freaks
=tee -- I pipe to double streams
Damian
example { coro {...} }
my $example = example();
my $example2 = example();
$example(); # 1
$example(); # 2
$example2(); # 1
$example(); # 3
Damian
# 6 7 8 9 10 50 51 52 53 54
print $co(10);# 55 56
print $co(10);# undef
print $co(10);# exception
Damian
t;reduce" and so
get all the handy metaoperators (sum, product, sum-of-squares, monotonicity,
first-true, first-defined) we've been missing to date.
Damian
[*] Okay, that's not strictly true. Evil Damian is already contemplating how
to implement n-ary reduction in Perl 5. Bwah-ha-ha-ha!
I will be releasing a full description of the new capturing semantics in the
next day or two. It will be appended to the appropriate Synopsis, but I'll
also post it here. It may be as soon as tomorrow, but I'm away teaching this
week, so my time is restricted.
Damian
Autrijus wrote:
/me eagerly awaits new revelation from Damian...
Be careful what you wish for. Here's draft zero. ;-)
Note that there may still be bugs in the examples, or even in the design.
@Larry has thrashed this through pretty carefully, and Patrick has implemented
it for PGE, but it
I think it would be better to leave the multi-dot
syntax to be visually unambiguous as a version number.
Damian
"I love bug-eyed monsters" }
Yes, I think this is the right answer. Much better not to multiply entities
without necessity.
Well done, Patrick!
Damian
t; To: $";
DC> }
since files and dirs are internal aliases (their names are in <>),
shouldn't those match accesses be $/ and $/?
Sure. Just as $42 is a shorthand for $/[42], so too $ is a shorthand
for $/.
Damian
with
Perl 5's $1, $2, $3...
But that's only the opinion of one(@Larry), not of $Larry.
Damian
rns a C object whose ...
string value is the complete substring that was matched
by the entire rule...
So the old $0 is just ~$/
Damian
, or some other kind of $n-1 value. If C (and
C, C, C) was a "subtract one" operator, you could write:
my $n = prompt "How many elems? ";
print @array[1st..($n)th];
instead of the out-by-one-prone:
print @array[0..$n-1]
Hmmm.
Damian
hy @1 shouldn't mean $1[]
and %1 shouldn't mean $1{}.
It *does*. According to the recent capture semantics document:
> Note that, outside a rule, C<@1> is simply a shorthand for C<@{$1}>,
and:
> And, of course, outside the rule, C<%1> is a shortcut for C<%{$1}>:
Damian
orthogonal for
practical use. ;-)
Damian
rue" if $p; # :p with no argument
$p //= 42; # :p with no argument
...
}
Yes, I was thinking along the same lines. C as a default seems
to be more accurate and useful than C.
Damian
g out in Perl, that something is $_. Now we're proposing unary
dot as a method call in which you can leave something out. If you were
an average Perl programmer and had to guess what that something was,
what would you guess?
Damian
pply a series of properties to a value:
$propped = [but] $value, @properties;
Personally I think a metaoperator with that many uses is more than Swiss-Army
enough to be in the core of Perl 6.
Damian
negative comparisons against explicit
(compile-time) junctions. That is, against expressions that explicitly use
|/&/^ or any/all/one/none.
Negative comparisons against implicit (run-time) junctions:
if $note != $bad_note {...}
still have to be allowed.
Damian
Larry wrote:
Actually, I think Damian's original formulation is sufficiently clear.
Me too! ;-)
I think that a standard [.] abbreviation for all
postcircumfix operators within [op] reductions would be a useful bit of dwimmery.
Damian
501 - 600 of 1296 matches
Mail list logo