Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Re: SOP6W

by TheDamian (Vicar)
on Apr 25, 2003 at 22:05 UTC ( [id://253270]=note: print w/replies, xml ) Need Help??


in reply to Re: SOP6W
in thread SOP6W

Since Perl6 will treat any code as "old code" unless it starts with one of the new keywords...
That's not quite right. Perl 6 will treat code as Perl 5 code if (and only if) the first executable line in the program is a package statement.

And, yes, we're going to need some way to distinguish Perl 6 code from Perl 5 code. Because there are a few simple cases that mean completely different things in Perl 5 and Perl 6. For example:

print $hash{bang};

In Perl 5 that means: print the value of the entry of %hash whose key is "bang".

In Perl 6 that means: print the value of the entry of the hash referred to by $hash whose key is "bang".

How could we distinguish Perl 5 and Perl 6 code? I'd suggest we add a <code6> flag and have the monastery render code marked as Perl 6 in a different font. For example, the submission:

    We're going to need some way to distinguish:
    
    <code>
        print $hash{bang};  # entry 'bang' of hash %hash
    </code>
    
    from:
    
    <code6>
        print $hash{bang};  # entry 'bang' of hash %{$hash}
    </code6>
might be rendered:
We're going to need some way to distinguish:
    print $hash{bang};  # entry 'bang' of hash %hash
from:
    print $hash{bang};  # entry 'bang' of hash %{$hash}

Note: I've used a red-shift/blue-shift visual pun here, but in reality we'd need to use distinct font faces -- perhaps serif for Perl 5 and sans-serif for Perl 6 -- so as not to disadvantage those with impaired colour vision.

Using a separate mark-up tag would also support those monks who (through necessity or by choice) use a non-visual browser.

Replies are listed 'Best First'.
(Re:)+ SOP6W
by rir (Vicar) on Apr 27, 2003 at 04:29 UTC
    How could we distinguish Perl 5 and Perl 6 code? I'd suggest we add a <code6> flag and have the monastery render code marked as Perl 6 in a different font.

    Personally I find such conventions easy to quickly forget with disuse because the association of font and language is arbitrary. I think this will not be of much help to occasional users or first-timers here. I see a lot of edits to add code tags and such now.

    I like this idea, the idea just doesn't address the problem as I was envisioning it.

    Something like halley's suggestion puts the issue explicitly in front of every seeker. Perhaps to the left of the Title entry widget something like a required selection widget:

    This post relates to: Perl5 Perl6 Both N/A Don't Know

    Whether the monastery would want to make someone who selects Dunno jump through more hoops before seeking wisdom is a tough question for me. I find such stealth dialogs unfriendly.

      Personally I find such conventions easy to quickly forget with disuse because the association of font and language is arbitrary.
      In general, of course, you're right. But in this particular case we're talking about two successive versions of the same language. So we have a clear temporal sequence. So I think we can have a very simple and self-evident mnemonic: use an older-looking font for the older language.
        self-evident mnemonic: use an older-looking font for the older language.

        Excellent idea but the devil is in the details. Without using antique fonts I'm still not sure I'd know which is which. I think many people could not sequence monospaced fonts invented after the typewriter. At least not those that I would endorse for use here.

        You place the onus on the seeker to know which Perl version he uses and to know the PM arcana show that to his readers. I'd rather see something like the required selection box modify the behavior of a <code> tag. And additionally have specific code or perl tags for the more expert user.

        I did not make it clear earlier: I'd expect that one result of the selection list would be an information box near the title of the node, and perhaps its replies.

        (I'm responding to your earlier post since your current one has clarified it for me.)

Re: Re: Re: SOP6W
by The Mad Hatter (Priest) on Apr 25, 2003 at 22:29 UTC
    Hmmm. This is a little OT, but how would you do the equivalent of print $hash{bang}; in Perl 6? print %hash{bang};?

    Maybe I should start reading the Apocolypses or something...

      how would you do the equivalent of print $hash{bang}; in Perl 6? print %hash{bang};?
      Exactly. In Perl 6 the sigils for arrays (@) and hashes (%) are an intrinsic part of the variable name and consequently don't change when the variable is accessed.
      Maybe I should start reading the Apocolypses or something...
      Good idea. They're most easily accessed at: http://dev.perl.org/perl6/apocalypse/.

      The Exegeses and Synopses are also quite useful.

      how would you do the equivalent of print $hash{bang}; in Perl 6? print %hash{bang};?
      That's right. I think sigils on hashes and arrays (when accessing elements or slices) are one of the most confusing things for beginners, and this is an effort to correct that. I think $hash{bang} can be optionally $hash.{bang} (remember "->" is changing to "."), but you can leave out the '.' since its unambiguous either way.
Re: Re: Re: SOP6W
by diotalevi (Canon) on Apr 28, 2003 at 02:20 UTC

    I had to visit this page using IE to see what you meant. My Mozilla client displays everything sans formatting. However this happens, it needs to be visible within the text and not merely an applied style.

      Which is exactly why I suggested distinguishing tags.

      However, perhaps the correct answer is for senior monks to start using a standard convention when the language in question is not obvious from context:

      # P5 print $foo{bar}.baz(); # bar entry of %foo, # then concat result of baz()
      vs:
      # P6 print $foo{bar}.baz(); # call baz() method on # bar entry of %$foo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-20 03:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found