Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Why does Perl have typeglobs?

by Anonymous Monk
on Jul 08, 2014 at 19:41 UTC ( [id://1092780]=note: print w/replies, xml ) Need Help??


in reply to Why does Perl have typeglobs?

Why does Perl have typeglobs? Yes, I understand that they are symbol table entries, but why can they hold several completely unrelated things - scalars, arrays, filehandles?

Because they are symbol table entries ... the symbol table, where completely unrelated things (variables) are held

If they weren't in the symbol table, they would be in the lexical pad (symbol table)

Is there some technical reason for that?

Yes, its drawn that way

Or was that just Larry's idea?

Larry , like all great inventors, borrowed lots of good ideas, and then he drawn-ed it

So, yeah, why are typeglobs the way they are?

Because

If they weren't the way they are, what way would they be?

SCALAR_table ARRAY_table HASH_table CODE_table IO_table FORMAT_table

Hmm, six individual variables tables, versus one umbrella table, hmmm

Why does perl have sigils to begin with? Or compact syntax for patter matching?

:P

Replies are listed 'Best First'.
Re^2: Why does Perl have typeglobs?
by Anonymous Monk on Jul 08, 2014 at 19:59 UTC
    Because they are symbol table entries ... the symbol table, where completely unrelated things (variables) are held
    You know, Perl is not the only programming language that makes use of symbol tables! And other language (that I know of) dont have anything like typeglobs.
    Hmm, six individual variables tables, versus one umbrella table, hmmm
    ? Why would you need different symbol tables? Different keys for different things would suffice. Perl's symbol table is just a hash... (well, I would be REALLY surprized if it weren't so)

    But now that I think of it, yeah... It was probably an attempt to save memory. Smaller symbol tables, fewer structs in them, fewer calls to malloc... That kind of fits with the idea context. Still pretty strange. I'm sure Perl programmers don't use that feature very often, if at all.

      Perl's symbol table is just a hash
      Indeed. A hash of hashes, in a way:
      use warnings; use strict; sub T { 42 } our $T = 24; *T = *STDOUT{IO}; print { *T{IO} } ${*T{SCALAR}}, ' ', *T{CODE}->(), "\n";
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        Not a hash of hashes, a hash of globs. Not only is the syntax different, so is the implementation. A glob is a struct, not a hash table.

Log In?
Username:
Password:

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

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

      No recent polls found