Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20

by BrowserUk (Pope)
on Nov 23, 2013 at 12:11 UTC ( #1064034=note: print w/ replies, xml ) Need Help??


in reply to Re^2: use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20
in thread use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20

I find the current syntax ugly and not readable:

Weird isn't it how differently people perceive particular syntaxes. I find the (long form) dereference syntaxes completely consistent and eminently readable (provided they are formatted correctly; which is short-hand for saying: the way I do it :)

  • ${ <thing> }: reference thing as a scalar.
  • @{ <thing> }: reference thing as an array.
  • %{ <thing> }: reference thing as a hash.

The internal whitespace around thing is imperative IMO, and with it, it is (I find it) totally clear, concise and consistent. The three holy Cs of syntax.

Personally, I would much rather have seen the short-forms ($$ref, @$ref & %$ref) removed than have another, less concise, less orthogonal, less consistent, less in-keeping-with syntax, added.

Hm. That last part isn't quite right; let me try that again.

  1. Pointlessly more verbose.
  2. Totally arbitrary.
  3. Utterly inconsistent (with anything).
  4. Confused and confusing.
  5. Completely out of keeping.
  6. Muddled and muddling.
  7. Like fitting a wing mirror to your garden shed.

Simply the pointless, capricious, because-we-can assertion of the ability to foist whimsy on us muggles. Of course, no one has to use it; but some will, and thus the damage is done.

In short, exactly what has gone wrong with p5p for the last few years.


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".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re^3: use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20
Select or Download Code
Re^4: use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20
by tobyink (Abbot) on Nov 23, 2013 at 16:32 UTC

    Indeed. And if postfix dereferencing was deemed so necessary, I think there are better ways it could have been accomplished. In particular, if autoboxing were made a core feature (and there are widely used autoboxing extensions on CPAN already as proof of concept) then we could just define methods:

    sub SCALAR::SCALAR { ${+shift} } sub ARRAY::ARRAY { @{+shift} } sub HASH::HASH { %{+shift} }

    And hey presto! Postfix dereferencing!

    my $scalar = $sref->SCALAR; my @array = $aref->ARRAY; my %hash = $href->HASH;
    use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
      Agreed!

      Autoboxing on compiler-level would be such a bless...

      ATM we need weird hacks to achieve this in the proof of concepts you are mentioning. (manipulating UNIVERSAL, overloading operators,...)

      Cheers Rolf

      ( addicted to the Perl Programming Language)

      In particular, if autoboxing were made a core feature ...

      I see no purpose or benefit in autoboxing either. Pseud-OO doesn't float my boat in any way whatsoever.

      See Re: What are the drawbacks of autobox? and Re^3: What are the drawbacks of autobox? and Re^5: What are the drawbacks of autobox? if you are interested in details, but in a nutshell, I see not just zero value, but negative value in wrapping over simple, obvious & well understood data abstractions like arrays and hashes in syntactic sugar to make them look like objects.

      Some concepts and paradigms neatly lend themselves to object->action(args) notation, but for others it's a clunky, unhelpful force-fit that serves only to dumb-down the language, as if programmers are only capable of handling a single syntactic form.

      Authors could reduce every sentence to the iconic 'The cat sat on the mat' form, rather than use forms like 'Upon 400 knot Persian silk rug, the feline reposed contently'; but damn literature would be boring.


      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".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        The advantage of autoboxing, is not to make this easier:

        my $error = 3.1415927->minus( 22->divide( 7 ) )->abs();

        But rather, if I write a function that deals with $href entirely though method calls rather than the built-in keywords, and document that I have done so, then somebody calling that function is now able to pass it, instead of a hashref, a blessed object providing the same interface; i.e. polymorphism.

        This can be achieved somewhat using tied variables, but the interface is very low-level - it's not easy to, say, quickly override the order a foreach loop will traverse an array.

        Besides which, in the former example you are hideously breaking encapsulation by using the assignment operator! ;-)

        (my $error)->set_value( 3.1415927->minus( 22->divide( 7 ) )->abs() );
        use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

        Authors could reduce every sentence to the iconic 'The cat sat on the mat' form, rather than use forms like 'Upon 400 knot Persian silk rug, the feline reposed contently'; but damn literature would be boring.

        Iíd have boring code over unreadable code any time. Code isnít supposed to have literary merit; itís supposed to be consistent.
      I agree. Correct autoboxing is the correct solution, not throwing arbitrary symbol characters at it. I know that there is no support anywhere in the mechanics of perl to have correct autoboxing. However, this current solution is the wrong solution and will not help promote perl, and likely will help detractors continue to detract. Features should be evolving in the direction of Perl 6 where possible, not wander tangentially in odd directions.

      I know this was discussed extensively by rjbs on the list. I think in this case this was promoted because of too much echo on p5p.

      my @a=qw(random brilliant braindead); print $a[rand(@a)];

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2014-11-01 01:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (227 votes), past polls