in reply to Snarky comments on the ddj perl quiz

2. scalar But scalar isn't a data type, or if it is, perl only has two data types, list and scalar. And there are fewer ways you can use a list than a scalar, so the correct answer is "list".

You know, I usually see Scalar as a data type. It's even mapped to SV* when you go to C. And no, when you consider scalar as a data type, you still have Array, Hash, Glob and Code. And yes, all of them are SV* also (the SV struct is binary compatible with all of them). Or did I miss something?

  • Comment on Re: Snarky comments on the ddj perl quiz

Replies are listed 'Best First'.
Re^2: Snarky comments on the ddj perl quiz
by ysth (Canon) on Aug 23, 2007 at 11:21 UTC
    I say "scalar isn't a data type" because all data is either a scalar or a list of scalars, so a scalar isn't really a type of data, just like dog isn't a type of poodle.

    Internally, yes, there are data types representing hashes, arrays, opcodes, etc., but at the Perl language level, arrays, hashes, globs, and scalars are variable types, not data types. And the only thing you can do with those variables is get data from them or put it into them, and that data is always a scalar or list of scalars.

      What do you mean a dog isn't a type of poodle? How else are you going to discriminate between Tory Bliar and all the other poodles?