Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^7: use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20 (demerphq mistaken?)

by ikegami (Pope)
on Dec 01, 2013 at 17:27 UTC ( #1065164=note: print w/ replies, xml ) Need Help??


in reply to Re^6: use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20 (demerphq mistaken?)
in thread use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20

The result of the evaluation of an identifier with its sigil may be coerced to something diferent depending on the context in which that evaluation is effective

That's not how context works at all, but even if you only consider list context, you still have:

  • @{ ... } evaluates to an array or a list.
  • @{ ... }[1,2] evaluates to a list.
  • %{ ... }[1,2] evaluates to a list.
  • %{ ... } evaluates to a hash or a list.
  • *{ ... } returns a scalar (glob).
  • *{ ... }{ARRAY} returns a scalar (reference).
  • &{ ... } can evaluate to a list or a scalar.
  • ${ ... }->() can evaluate to a list or a scalar.

so in list context,

  • @... can evaluate to an array or a list.
  • %... can evaluate to an hash or a list.
  • $... can evaluate to a list or a scalar.
  • &... can evaluate to a list or a scalar.
  • *... can evaluate to a glob or a reference.

Of course they do, at least since perl4 patchlevel 36 (or 19 on Atari).

I can't verify that claim, but I doubt it. At the very least, it hasn't been the case since 5.6 which was released 14 years ago. There is not a single sigil that indicates the type of the value returned.

the evaluation of an identifier bare of any context depends on its sigil.

Noone said otherwise. Of course it depends on the sigil. @a is not the same as $a.

The premise demerphq put forth is that the sigil is an indicator of the type of value to which the sigiled expression evaluates to. That's clearly not the case. You can't break a model that doesn't exist.


Comment on Re^7: use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20 (demerphq mistaken?)
Select or Download Code
Re^8: use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20 (demerphq mistaken?)
by shmem (Canon) on Dec 01, 2013 at 20:54 UTC
    That's not how context works at all

    I'm baffled. So you are telling me that I don't know about context in Perl?

    • %{ ... } evaluates to a hash or a list.

    And how, pray, is the "or" resolved? There.

    Anyways, you are right. Im sick of tennis match like conversations. I'm not here to win.

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

      Anyways, you are right. Im sick of tennis match like conversations. I'm not here to win.

      you'll never be pope with that attitude ;) :D

      I'm baffled. So you are telling me that I don't know about context in Perl?

      I can't comment on what you know, just on what you say.

      Context doesn't cause values to be coerced. Operators return different values based on the context. That's why $x = (4,5,6); and @a = (4,5,6); $x = @a; result in different values in $x.

      And how, pray, is the "or" resolved? There.

      I'm not sure what the means. Are you asking how it's determined when %... evaluates to a hash and when %... evaluates to a list? It's based on the operator that parses it. e.g. keys(%foo) or \%foo vs print(%foo).

Re^8: use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20 (why the downvotes?)
by smls (Friar) on Dec 11, 2013 at 14:22 UTC

    Anyone care to shed light on why ikegami's post received so many downvotes?

    Is there a mistake in his overview of the return types of sigil'ed expressions, or in his general conception of Perl contexts and lists?
    I'm asking because my own conception matches what he wrote, so if it's wrong I'd be interested in learning why.

      Trying to split hairs is often unconvincing and then annoying to those who disagree.

      - tye        

        I don't call @... return a scalar or an array an exceedingly small difference from @... returning a list. I'm not even sure how the difference could be greater.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2014-08-29 02:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls