Deutsch English Français Italiano |
<87frp3itsk.fsf@doppelsaurus.mobileactivedefense.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!2.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Rainer Weikusat <rweikusat@talktalk.net> Newsgroups: comp.unix.shell,comp.unix.programmer,comp.lang.misc Subject: Re: Command Languages Versus Programming Languages Date: Thu, 10 Oct 2024 21:31:39 +0100 Lines: 112 Message-ID: <87frp3itsk.fsf@doppelsaurus.mobileactivedefense.com> 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> <20241010120827.867@kylheku.com> Mime-Version: 1.0 Content-Type: text/plain X-Trace: individual.net Htlca5IOn5jNglhcIrINaghx8dcC4IJZNjow8Kw+0a5tOiTPo= Cancel-Lock: sha1:6focjzhmDXvWGKKONRCpyOIddJQ= sha1:UZAVkInEhjLkagHu4snh0A22xv4= sha256:4W3g5RyvQu3EhPnz2OP6m3QVqyArcYM0VL1THX65lHE= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Bytes: 5486 Kaz Kylheku <643-408-1753@kylheku.com> writes: > On 2024-10-10, Rainer Weikusat <rweikusat@talktalk.net> 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 > > Interpreter? Perl has some kind of compiler in it, right? The Perl compiler turns Perl source code into a set of (that's a conjecture of mine) so-called "op trees" whose nodes contain pointers to built-in functions and pointers to "op subtrees" supplying arguments for these and the interpeter/ virtual machine then evaluates these op trees to run the program. [...] >> know the type of a variable without being told about it? Obviously, not >> at all. > > But it's not exactly type, because $x means "scalar variable of any > type" whereas @x is an "array of any type". $x means 'scalar variable'. There's no furher differentiation of that at the language level despite there are two kinds of scalar variables at the implentation level, scalars whose values are "values" of some sort (ie, strings or numbers) and scalars whose values are references to something. @x is an 1-D array of scalars. > That's quite useless for proper type checking and only causes noise, > due to having to be repeated. > > Actually typed languages don't use sigils. How is that? > > The type of a name is declared (or else inferred); references to that > name don't need to repeat that info. The Perl type system is based on using different namespaces for different types which means the type of a variable is part of its name. This has the advantages that declaration syntax is concise and that it's possible to have different kinds of variables with the same name. It's also not really specific to Perl as C uses a similar model for structures declarations and definitions. The obvious disadvantage is that every variable name in Perl and every use of a variable in an expression has and additional meta-information character associated with it. The actual rules outside of declarations are also more complicated because of the underlying idea that $ would be something like a singular article in a spoken language an @ a plural article. This means that elements of arrays and hashed are referred to using a $ prefix and not @ or %, eg, my @a; $a[0] = 1; or my %h; $h{goatonion} = 'winged cauliflower'; I think that's rather a weird than a great idea but it's internally consistent and as good (or bad) as any other language ideosyncrasy. It's certainly less confusing than the : as expression separator in supposedly punctuation-free Python which tripped me up numerous times when initially starting to write (some) Python code. Things only start to get slightly awful when references become involved. In Perl 4 (reportedly, I've never used that) a reference was a variable holding the name of another variable, eg $b = 1; $a = 'b'; print $$a; # prints 1 Perl 5 added references as typed pointers with reference counting but retained the symbolic referenc syntax. For the example above, that would be $b = 1; $a = \$b; print $$a; # also prints 1 Thinks start to become complicated once references to complex objects are involved. Eg, @{$$a[0]} is the array referred to by the first item of the array $a refers to and ${$$a[0]}[0] which seriously starts to look like a trench fortification with barbed-wire obstacles is a way to refer to the first element of this array. The {$$a[0]} is a block returning a reference to an array which the surrounding $ and [0] then dereference. The { } could contain arbitrary code returning a reference. But for the simple case of dereference-chaining, this is not needed as it's implied for adjacent subscript (for both hashes and arrays) which means the simpler $$a[0][0] is equivalent to the other expression.