The "scrap your boilerplate" scheme for generics in Haskell addresses
traversals, queries, transformations, parallel zipping and the like.
I've only briefly felt like I understood it, so I was going to
revise before trying to adapt it to Perl 6.
(Any lambdacamels out there that do understand th
Tim Bunce wrote:
Thinking in terms of grammars, I'd ask the question: could grammars be
used to match tree-like data structures? I think the current answer is no.
Grammars are too tightly bound to the concept of a position in a linear
string.
But I have a nagging suspicion that this is a very po
Hi,
Is the ordering of the output of this example in S05 correct?
( http://perlcabal.org/syn/S05.html#Modifiers )
$str = "abracadabra";
if $str ~~ m:exhaustive/ a (.*) a / {
say "@()";# br brac bracad bracadabr c cad cadabr d dabr br
}
I assume that there is an ordering
Hello,
In S05, is listed under named assertions and isn't explicitly
mentioned in the section on character classes.
Can sp be used in character classes, in particular to include or
exclude space (U+0020)? eg. ,
Is there another way to do this, maybe <[\ ]> escaping?
Thanks,
Brad
--
There
Hello,
Regarding this from perlvar:
Remember: the value of $/ is a string, not a regex. awk has to
be better for something. :-)
It seems to me that the DFAable rules would intertwingle nicely as
a non-backtracking stream chunker. Is the form of per-filehandle
input record separa
Larry Wall wrote:
But the point is *not* to force it one way or the other--the point is
that many such functions would probably prefer not to commit one way or
the other, and they can't do that if they automatically throw away the
"dimensional" information.
The dimensional information has to
Hello,
I'm still wrapping my head around the recent changes to rules but at
the moment I feel slightly uneasy about the context dependence of
DFA prefix mode. The unease hasn't resolved into an example yet,
but my concern is that the interpretation and result of a pattern
varies with the dynamic
TSa wrote:
TSa wrote:
Note that the superclass interface of roles should be mostly inferred
from the usage of next METHOD. As such it is a useful guidance for
error reports in the class composition process.
Actually 'next METHOD' doesn't catch all superclass interface issues.
There is the simp
Sam Vilain wrote:
TSa wrote:
is this subject not of interest? I just wanted to start a
discussion about the class composition process and how a
role designer can require the class to provide an equal
method and then augment it to achieve the correct behavior.
Contrast that with the need to do th
Both Data::Dumper and Storable provide hooks to customize serialization
($Data::Dumper::Freezer|Toaster, STORABLE_freeze|_thaw).
Other modules like YAML and Clone could also possibly reuse a
common state marshalling interface.
Is there some common element to this process which can be gathered
in
Mark Stosberg wrote:
In the Objects chapter, a WALK pseudo-class is spec'ed for using
when calling sets of methods:
http://feather.perl6.nl/syn/S12.html#Calling_sets_of_methods
These are the arguments listed that can be used with WALK:
:canonical # canonical dispatch order
:asce
Just some random thoughts about self-referential structures
and their literal representations:
$ perl -MData::Dumper -e '$a=[1,\$a]; print Dumper($a)'
$VAR1 = [
1,
\$VAR1
];
$ perl -MYAML -e '$a=[1,\$a]; print Dump($a)'
--- &1
- 1
- !perl/ref:
=: *1
$ pugs -e 'my @a =
Hello,
It seems that sprintf is will still be around in Perl 6 [1],
and that sprintf formats will be available using the .as() method.
While looking at some Python docs [2] I noticed two things that might
be worth stealing; a sprintf operator (%) and named parameters in
the format string:
a =
Hi,
I used AI::Prolog once briefly, and that's the extent of my logic programming
knowledge. There do seem to be a few Perl 6 features that may be useful for
logic programming, although I'm not really qualified to judge.
How would one assert facts and rules in Perl6? How would one know
that a
S06/Splicing finishes with:
A quasiquote is not a block (even if the delimiters are curlies),
so any declaration of a variable is taken to be part of the block
surrounding the macro call location. Add your own {...} if you want
a block to surround your declarations.
I read this as meaning th
On 19/02/06 03:48, Jonathan Lang wrote:
I don't see why you'd need a universal anti-backwhack, any more than
you need universal quote delimiters.
Here-docs are usually safe to quote any amount of line noise,
but I take your point.
I could see introducing
On 18/02/06 03:10, Larry Wall wrote:
On Sat, Feb 18, 2006 at 01:57:18AM +0200, Brad Bowman wrote:
: $a is spliced into the say as either a string or AST, not
: as a runtime use of $a. If the snippet was:
:
: $a = '$a';
: return CODE { say $a };
:
: Then we'd (eventually) get
On 18/02/06 12:23, Jonathan Lang wrote:
Piers Cawley wrote:
And backwhacking braces in generated code is *not* a pretty solution
to my eyes. I'd *like* to be able to have a quasiquoting environment
along the lines of lisp's backquote (though I'm not sure about the
unquoting syntax):
Let me s
On 18/02/06 07:49, Damian Conway wrote:
There is already a mechanism for this. You simply turn off all variable
interpolation, and interpolate any the variables you wish to interpolate
via block interpolations. Or, more simply, only turn on block
interpolation in a non-interpolating string:
Hi again,
L
Is it possible to refer to a variable in a CODE quotation without
splicing it in as an AST or string? I can't see how this is
be possible under S06, unless using OUTER:: is intended to be
a non-splicing variable mention.
The sample snippet in S06 seems simple but got me confuse
Hello,
When building code strings in Perl 5 I usually write the code,
then wrap it in double quotes, then "\" escape everything light blue
under syntax highlighting. I was wondering if there'll a better
way in Perl 6.
I thought it would be nice to define the variables you wish to
interpolate
Hi,
I've read and reread the macro explanation but I'm still not entirely
clear on number of things. The questions and thoughts below are based
on my (mis)understanding.
On 03/02/06 02:05, Larry Wall wrote:
Macros are functions or operators that are called by the compiler as
soon as t
On 14/01/06 00:59, Larry Wall wrote:
That doesn't seem sufficiently general. I'd rather see some context
that can apply a signature to the head of a list and treat the
"unslurped" part as unmatched. Maybe a "for" loop could be taught
to supply such a context, or a "when". Or maybe it's just th
On 13/01/06 20:36, Dave Whipp wrote:
Is there some way to associate alternate codeblocks for different
patterns (i.e. local anonymous MMD)?
Is it possible to have an anonymous multi sub?
This would seem to require new syntax for combining two anonymous
definitions.
Of course we want everythin
Well, @Larry has been researching attribute grammars for a month or
two now, which are an efficient (programmer-wise, not necessarily
processor-wise) method for specifying computations over trees. The
only syntax we've seen is that of Language::AttributeGrammar and TGE,
whose roots come from UU
But in Perl 5 to "navigate" complex structures one needs ad-hoc
solutions. I wonder if something is planned in Perl 6 as a means to do
that through a syntactically convenient construct with ad-hoc-isms
pluggable in in the form of suitable hooks (e.g. .on_node( { code; ... }
), etc.) that woul
This is only about transliteration (tr///), not rules in general.
So you are only matching a fixing set of strings at a certain position.
If one string is the prefix of another, the longer is preferred.
If there are two identical match strings, the replacement corresponding
to the first is used.
On 15/12/05 23:35, Larry Wall wrote:
On Thu, Dec 15, 2005 at 06:50:19PM +0100, Brad Bowman wrote:
: The "first in order" rule is more flexible, the user can sort their
: arrays to produce the longest input rule, or use another order if that is
: preferred.
What possible use is a us
Hi,
S05 describes an array version of trans for transliteration:
( http://dev.perl.org/perl6/doc/design/syn/S05.html#Transliteration )
The array version can map one-or-more characters to one-or-more characters:
$str.=trans( [' ', '<','>','&'] =>
[' ',
On 08/12/05 17:12, Larry Wall wrote:
> On Thu, Dec 08, 2005 at 11:14:16PM +0100, Brad Bowman wrote:
> : it may be acceptable with a "my" in the regex or limiting the
> : additions to declaring scope.
>
> I've gone around about that in my head lots of time, but there
Hello,
I'd like to get clarification on the scoping of variables
bound in a regex. It's described in S05 as follows:
External aliasing
* Instead of using internal aliases like:
m/ mv @:=+ $:= /
the name of an ordinary variable can be used as an "external
alias", like
Hello,
How can you match a literal "#" in a rule?
\# or only \x{23}?
S05 seems clear "# now always introduces a comment",
and \# is not listed in the escapes.
But then Perl 5 has \# so I assume it's just an omission...
Brad
--
A person who knows but a little will put on and air of knowledge
> 1. Asserted
>
> The usual case for Perl 6 functions, due to its default "Item"
> signature for parameters. In the example below, I assume that ::* cannot
> be changed freely to do away with ::*IO at runtime. (If it could, then
> assertions won't be of much use in general.)
>
> FWIW, I've been reading up on Scala's formulation of trait/class/delegation
> hierarchy, and I feel a bit like flipping through a puzzle book to look
> at the hints, if not answers. :-)
>
> http://scala.epfl.ch/docu/files/api/index.html
I misread "mutable" as "mumble" and thought they'd be
Hi
Autrijus' journal mentions quasiquoting (Perl 5).
I was wondering how that would work. Many languages use unusual
syntax for quasiquoting and code splicing but Perl 6 is already
nibbling into unicode.
Does that mean macros will be grafting and pruning the AST that
comes back from a quote/r
> Another alternative is to give the user the option of specifying such
> a unit when using the reduction meta-operator, but this seems to work
> against the whole point of [+] (which is brevity). If you want to
> specify your own unit, use '&reduce'.
Can't the appropriate identity just be prepen
> : ../method
> :
> : to mean $?SELF.SUPER::method, or however that's normally written.
>
> That's almost terminally cute, but I like it. Unless someone can
> think of a major objection (such as that it makes it too easy to use
> SUPER semantics rather than NEXT semantics), let's go with it.
> I guess the real question is whether ==> my $x is really assigning a
> list or binding an iterator to a Lazy slot somewhere. It feels like
> the latter is more useful. Which means that ==> @x can return as soon
> as it binds the iterator to @x.specs. It doesn't have to wait for all
> the valu
> What if you give it a 1-ary sub that you thought was slurpy, and in
> fact does something different (hmm, that doesn't seem very likely).
> How do we handle options and the like?
.assuming ? Although map would be simpler, clearer and more flexible.
> Still, semantics like that are dwimmery,
Hi,
<$*IN> ==> process() ==> print;
This A06 example got me thinking.
Could non-variadic subrountines in a pipeline be useful?
A single arg sub or block could be a map without the "map":
<$*IN> ==> &process ==> print;
# print map { process($_) } <$*IN>
(1..6) ==> { $_++ } ==> say;
A
> With cons based lists, past stream values are no longer referred to
> so can be reclaimed, but we have random access arrays.
>
> That's about where my wondering stopped.
It started again. @primesquares.shift would do it
Brad
Hi,
I've been wondering how to lazy lists will work.
The answer "Correctly, don't worry about it", is entirely acceptable...
The intent of this example in S06 seems clear, make @oddsquares
a lazily filled array of squares of odd @nums:
S06/Pipe operators
It [==>] binds the (potentially lazy
> No, S03 is probably just wrong there. Junctions are scalar values, and
> don't flatten in list context. Maybe we need something like:
>
> for =all(@foo) {...}
>
> to iterate the junction.
for all(1,2,3).values { say $_; }
reads nicely and works in pugs.
Also, flattening may get mess
Hi,
I'm trying to understand the following section in S03:
S03/"Junctive operators"
Junctions are specifically unordered. So if you say
for all(@foo) {...}
it indicates to the compiler that there is no coupling between loop
iterations and they can be run in any order or even in para
Once more, with less room to wriggle...
> > I'd guess the rule is "call 'em all and return a similarly
> > structured junction". How far off the mark am I?
>
> Unless you ask a question nothing is called.
Boolean context is clear, how about scalar:
my $a = rand(); # runtime variable
my $
Hi,
Assuming this is allowed, what will the .() calls below return?
Does the result depend on the calling context?
use junctions; # still required?
my @subs = ( sub { return 1 } ,
sub { return 2 } );
# call the closures in the junction
any(@subs).();
all(@subs).();
one(@s
Hi all,
S03 gives infix + a higher precedence than junctive
operators in the listed table, but that seems to contradict
the examples under "Junctive operators".
The relevant parts of S03 are:
Junctive operators
1|2|3 + 4; # 5|6|7
1|2 + 3&4; # (4|5) & (5|6)
47 matches
Mail list logo