Deutsch   English   Français   Italiano  
<ve9mml$3aiao$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Bart <bc@freeuk.com>
Newsgroups: comp.unix.shell,comp.unix.programmer,comp.lang.misc
Subject: Re: Command Languages Versus Programming Languages
Date: Fri, 11 Oct 2024 00:07:02 +0100
Organization: A noiseless patient Spider
Lines: 68
Message-ID: <ve9mml$3aiao$1@dont-email.me>
References: <uu54la$3su5b$6@dont-email.me> <87edbtz43p.fsf@tudado.org>
 <0d2cnVzOmbD6f4z7nZ2dnZfqnPudnZ2d@brightview.co.uk>
 <uusur7$2hm6p$1@dont-email.me> <vdf096$2c9hb$8@dont-email.me>
 <87a5fdj7f2.fsf@doppelsaurus.mobileactivedefense.com>
 <ve83q2$33dfe$1@dont-email.me>
 <87wmighu4i.fsf@doppelsaurus.mobileactivedefense.com>
 <ve8s6d$3725r$1@dont-email.me>
 <87o73rj3sr.fsf@doppelsaurus.mobileactivedefense.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 11 Oct 2024 01:07:01 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="e855f7326897fc9dc7def665be4b215a";
	logging-data="3492184"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX193HutsHDb2Tv+vW5SeLWTQ"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:k0ETDaU3PZsKlkT8lgDaLgtxh0E=
In-Reply-To: <87o73rj3sr.fsf@doppelsaurus.mobileactivedefense.com>
Content-Language: en-GB
Bytes: 3540

On 10/10/2024 17:55, Rainer Weikusat wrote:
> Muttley@DastartdlyHQ.org ignorantly rambled:
>> On Thu, 10 Oct 2024 16:09:49 +0100
>> 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.
> 
> For the purpose of variable declaration, how's the interpeter going to
> 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);

Why would you want to do this?


> $data = rand(128);
> @data = ($data, $data + 1);
> %data = map { $_, 15 } @data;
> 
> it's also convenient to type and easy to read due to being concise.

Adding shifted punctuation at the start of every instance of a variable? 
I don't call that convenient!

So, $ is scalar, @ is an array, and % is a hash?


> 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 and

Now I'm already lost. 'a' is an array, but it's being used with $? What 
would just this:

  a[0]

mean by itself?

> @a[-3 .. -1]
> 
> is a list composed of the three last elements of @a.

Sorry, these prefixes look utterly pointless to me. This stuff works 
perfectly well in other languages without them.

I can write a[i..j] in mine and I know that it yields a slice.

What would a[-3 .. -1] give you in Perl without the @? What would $a[-3 
... -1] mean?

What happens if you have an array of mixed scalars, arrays and hashes; 
what prefix to use in front of a[i]?