Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Keep It Simple, Stupid
 
PerlMonks  

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

by Anonymous Monk
on Nov 25, 2013 at 08:17 UTC ( #1064199=note: print w/ replies, xml ) Need Help??


in reply to Re: 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 don't think this is a good syntax. I would humbly suggest a better syntax is actually a new operator. Something like this:

But that does so much less than the proposed syntax, also it confuses assignment with dereferencing (dereferencing doesn't imply assignment)


Comment on Re^2: use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20
Re^3: use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20
by einhverfr (Scribe) on Nov 25, 2013 at 08:47 UTC

    Ok, this is a fair concern. The question is what sort of syntax would work when, say, passing in an argument to a function. One could have implicit assignments in a unitary left hand operator for example, something like:

    my $foo = somefunc(\= $bar);

    This would be contextually equivalent to %$bar or @$bar depending on what $bar references. The idea would be it means "what ___ references" and that gets coerced into a list or array after that point. Of course in this context, it would be coerced into a list (of possibly only one value)...

    In short if the \= operator was overloaded so that it could be either binary or unitary (left-hand), then the problem goes away.

      In short if the \= operator was overloaded so that it could be either binary or unitary (left-hand), then the problem goes away.

      An even worse idea :)

        If it is an even worse idea, then my conclusion is that this whole thing is a bad idea and we should just stick to the current dereference syntax, i.e. ${ $object->{foo} }.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2014-04-19 21:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (483 votes), past polls