playing with <>, two questions came to my mind:

a) why isn't it "regular" ?

    use Test;
    ok < foo bar bang >  ~~ List, "a list";
    ok < foo bar      >  ~~ List, "a list";
    ok < foo          >  ~~ List, "a list"; diag "actually a Str";
    ok < >  ~~ List, "a list";

not only it is an exception to a simple rule but it waste memorizable and short
way to write a 1 element list. as always with perl6, i trust the perl6
designers for having a very good reason and i'm curious: what is actually 
this good reason for such a weird behave.

b) shortest way to hash ?

i used %(< class foo id bar >) in my code


i know it sounds stupid but i'm very sorry not being able to write (and most
of all: read and edit)

    %< class foo id bar >

which isn't allowed ... but perl6 let me cheat: i can define a %
operator working with an extra space

    use v6; 
    use Rototo::html;

    sub H (*@data) { join '', @data }
    sub prefix:<%> ( List $l ) is tighter(&infix:<,>) { %(|$l) }

    say % < id foo class bar >;             # class => bar, id => foo
    ( % < id foo class bar > ).^name.say;   #   Hash
    say H br :id<foo>, :class<bar>;         #  <br id="foo" class="bar"/>
    say H br |% < id foo class bar >;       #  <br id="foo" class="bar"/>
    say H p  |% < id foo class bar >, "this is a good thing";
        # <p id="foo" class="bar">this is a good thing</p>

this is working but raised 2 questions:

* if it was so easy, why isn't it in perl6? 
    [ ] i missed the good paragraph of the documentation ?
    [ ] i'm going to do something very stupid ? 
    [ ] other, your answer here

* i just don't know way i need | in front of % ... it just works but for
  me %() was enought and explicit on what i wanted to get. can someone explain ?


Marc Chantreux,
Mes coordonnées: http://annuaire.unistra.fr/chercher?n=chantreux
Direction Informatique, Université de Strasbourg (http://unistra.fr) 
"Don't believe everything you read on the Internet"
    -- Abraham Lincoln

Reply via email to