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

Re: Thx, St. Larry, for the Beauty of Sigils

by LanX (Saint)
on Jul 26, 2019 at 20:19 UTC ( [id://11103480]=note: print w/replies, xml ) Need Help??


in reply to Thx, St. Larry, for the Beauty of Sigils

> I realize that Python people hate having to type sigils all over the place, and that they would find it ironic that this would be the thing I would write in praise of.

Many Python people just hate everybody who questions a little bit of their language. I think it's also due to the fact that many learn Python as first language and have problems accepting TIMTOWTDI.

The other problem is the frustrating learn curve of Perl, because we have a list form and a ref form of an array.

DB<2> $a = [A..Z] DB<3> @a = (a..z) DB<4> x $a[0], $a->[0] 0 'a' 1 'A'

That has many advantages but makes the syntax confusing.

I'd personally like to have any new syntax or pragma to "alias" $a and @a together at declaration time, such that I could write

my $a[]; #=> @a := @$a $a = [A..Z]; print "@a"; # A B C ... print $a[0]; # A

thus avoiding \ and -> in many cases.

The downside would be to loose the advantages of separate namespaces, but they are rarely used.

Though I don't know how to implement it or if it's even possible, without braking old code.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Replies are listed 'Best First'.
Re^2: Thx, St. Larry, for the Beauty of Sigils
by dsheroh (Monsignor) on Jul 27, 2019 at 07:34 UTC
    I think it's also due to the fact that many learn Python as first language and have problems accepting TIMTOWTDI.
    In my experience, that's not just first-language Pythonistas. Python has an explicitly anti-TIMTOWTDI philosophy ("There should be one - and preferably only one - obvious way to do it.") so you get problems with TIMTOWTDI even from people who also know other languages if they've drunk the Python Kool-Aid.
      > "There should be one - and preferably only one - obvious way to do it."

      The "Zen of Python" is a big pile of pseudo religious dogma which doesn't hold scientific scrutiny.

      For instance it says "Explicit is better than implicit." but Python does implicit declarations and implicit dereferencing.

      This reminds me about an article about religious dogmas I read recently: It described how a newer religions contain polemics against predominant neighboring religions at time of it's creation. Islam vs Christianity, Christianity vs Judaism, mainstream Judaism vs Samaritans and so on.

      The Zen of Python is best understood as an anti Perl polemic from back then.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Re^2: Thx, St. Larry, for the Beauty of Sigils
by shmem (Chancellor) on Jul 27, 2019 at 13:56 UTC
    The other problem is the frustrating learn curve of Perl, because we have a list form and a ref form of an array.

    No, we have plain variables and references to variables (and functions). The distinction between plain and reference variables is well done IMHO.

    But python is worse - it has list and tuple arrays

    qwurx [shmem] ~> python Python 2.7.15+ (default, Nov 27 2018, 23:36:35) [GCC 7.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> foo = (1,2,3,4) >>> bar = [1,2,3,4] >>> type(foo) <type 'tuple'> >>> type(bar) <type 'list'> >>> bar[0] = 5 >>> foo[0] = 5 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'tuple' object does not support item assignment >>> foo (1, 2, 3, 4) >>> bar [5, 2, 3, 4] >>>

    and it isn't obvious which is which by looking at the identifier. A tuple is inmutable, a list can be assigned to.
    This was a major WTF moment for me.

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
      > No, we have plain variables and references to variables (and functions).

      I was using my own wording for the distinction.

      But sorry "plain variable" is blah.

      The fact that other languages do implicit dereferencation in their syntax doesn't make them less plain.

      $a, %a and @a are in fact containers for references, to allow such implicit dereferencation. °

      So how are containers "plain" now?

      But Perl is more explicit* here, which helps understanding what is really happening if you do an assignment a=b in another languages, where they sometimes copy the content or the reference.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      updates

      °) e.g. $a[0] is by definition (\@a)->[0]

      *) "Explicit is better than implicit" quote from Python blah

        But sorry "plain variable" is blah.

        I was using my own wording for the distinction.

        perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
Re^2: Thx, St. Larry, for the Beauty of Sigils
by Jenda (Abbot) on Jul 27, 2019 at 21:11 UTC

    I could never understand what's supposed to be confusing about this.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

Log In?
Username:
Password:

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

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

    No recent polls found