Liste des Groupes | Revenir à cl misc |
Muttley@DastartdlyHQ.org ignorantly rambled:Why would you want to do this?On Thu, 10 Oct 2024 16:09:49 +0100For the purpose of variable declaration, how's the interpeter going to
Rainer Weikusat <rweikusat@talktalk.net> boring babbled:Muttley@DastartdlyHQ.org writes:>Its syntax is also a horrific mess.>
Which means precisely what?
Far too much pointless punctuation. An interpreter shouldn't need the vartype
signified by $ or @ once its defined, it should already know.
know the type of a variable without being told about it? Obviously, not
at all.
Perl has three builtin types, scalars, arrays and hashes and
each is denoted by a single-letter prefix which effectively creates
three different variable namespaces, one for each type. That's often
convenient, because the same name can be reused for a variable of a
different type, eg:
my ($data, @data, %data);
$data = rand(128);Adding shifted punctuation at the start of every instance of a variable? I don't call that convenient!
@data = ($data, $data + 1);
%data = map { $_, 15 } @data;
it's also convenient to type and easy to read due to being concise.
Outside of declarations, $ and @ really denote access modes/ contexts,
with $ standing for "a thing" and @ for "a number of things", eg
$a[0]
is the first element of the array @a andNow I'm already lost. 'a' is an array, but it's being used with $? What would just this:
@a[-3 .. -1]Sorry, these prefixes look utterly pointless to me. This stuff works perfectly well in other languages without them.
is a list composed of the three last elements of @a.
Les messages affichés proviennent d'usenet.