Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Porting (old) code to something else

by BrowserUk (Patriarch)
on Feb 16, 2015 at 15:20 UTC ( [id://1116879]=note: print w/replies, xml ) Need Help??


in reply to Porting (old) code to something else

I do not like the new whitespace issues that perl6 imposes on the code.

Sorry, could you clarify?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Replies are listed 'Best First'.
Re^2: Porting (old) code to something else
by Tux (Canon) on Feb 16, 2015 at 16:52 UTC

    Of course I can :)

    In perl6 the opening paren (() of a function cannot be separated from the function by whitespace:

    Legal in perl5: my $foo = foo( 1 ); # A my $foo = foo(1); # B my $foo = foo (1); # C my $foo = foo ( 1 # D );

    For reasons I explain in my style guide MY preference is C. Perl6 only supports A and B.

    This is only an example. The syntax rules go deeper than that, causing the dot (.) to be special too, so that

    my $foo = $object->method (1) ->method (2) ->method (3);

    chaining as allowed in perl5 (break to a newline wherever you like), would NOT translate to

    my $foo = $object.method(1) .method(2) .method(3);

    This is bad (IMHO), see:

    $ cat t.pl use v6; class C { has Int $.x is rw = 0; method foo (Int $i) { $!x += $i; return self; } method bar (Int $i) { $!x -= $i; return self; } } C.new().foo(1).bar(2).say; $ perl6 t.pl C.new(x => -1) $ cat t.pluse v6; class C { has Int $.x is rw = 0; method foo (Int $i) { $!x += $i; return self; } method bar (Int $i) { $!x -= $i; return self; } } C.new() .foo(1) .bar(2) .say; $ perl6 t.pl ===SORRY!=== Error while compiling t.pl Two terms in a row at t.pl:11 ------> ⏏.foo(1) expecting any of: infix stopper infix or meta-infix statement end statement modifier statement modifier loop

    This is because a leading dot (after whitespace) will see the next word as method on the current topic ($_) instead of as a method on the previvious "thing". As the previous line has no trailing semi-colon, I would prefer the default to be different. The perl6 core dev people state it is possible with a backslash:

    cat t.pl use v6; class C { has Int $.x is rw = 0; method foo (Int $i) { $!x += $i; return self; } method bar (Int $i) { $!x -= $i; return self; } } C.new()\ .foo(1)\ .bar(2)\ .say; $ perl6 t.pl C.new(x => -1)

    But do you want your code to look ugly like that? I do not!


    Enjoy, Have FUN! H.Merijn
      For reasons I explain in my style guide MY preference is C.

      Ah! Okay.

      No further rational discussion is possible (for me) here because I find your preferred style utterly abhorrent :)


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
      In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

      I did think of one serious -- and hopefully non-controversial -- question regarding your use of Slang for your module.

      If at some point in the (hopefully far) future, it becomes necessary for someone else to take over your module -- someone who doesn't share your stylistic preferences -- how hard will it be for them to undo your use of Slang?

      I'm not expecting an answer; but it's something to think about.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
      In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

        You'll get an answer, as this is a (very) good question to consider.

        It there would not have been this slang (for me), this module - as it currently is - would not have happened at all. So what is better/worse?

        My annoyance of having to write - what I consider - ugly code is so that I refuse to do so. Having this slang causes me to produce perl6 code - be it in a deviating style - with fun.

        Conversation with many of the perl6 dev people have already proven this to be useful. I found several bugs in the core and have - together with perl6 people - also made some amendments.

        The person(s) I am working with already concurred to use my style/slang. At least it is (very) consistent. The only thing I have to think about to make them happy is to not use tabs as leading whitespace (which already caused my Makefile to break a couple of times).

        Warning: the vortex that'll draw you into perl6 development is strong. If you cannot handle the force, do not get near :)


        Enjoy, Have FUN! H.Merijn

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1116879]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-03-29 10:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found