Sujet : Re: Procedural, Functional, String [was Re: The joy of FORTRAN]
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : alt.folklore.computers comp.os.linux.miscDate : 30. Sep 2024, 00:21:49
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vdcned$1tmdr$6@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14
User-Agent : Pan/0.160 (Toresk; )
On Sun, 29 Sep 2024 06:55:21 -0700, Lars Poulsen wrote:
On 29/09/2024 00:06, Lawrence D'Oliveiro wrote:
>
All OO languages are in fact procedural.
The opposite of “procedural” is “functional”, not “OO”.
I need to do some reading. My understanding of the difference is clouded
by the fact that a subroutine is a procedure, but becomes a function if
it delivers a return value. (Yes I am that old).
That’s my interpretation, too. But all too commonly you will come across
“procedural” used as some kind of synonym for “not OO”.
My interpretation is: “functional” -- “evaluates to a value”; “procedural”
-- “has some effect on machine/world state”.
The languages I like are primarily procedural, but also allow for useful
functional constructs.
So what syntax *do* you want to use to join strings?
S3 = string_join(S1, S2) .. or .. S3 = S1.S2 .. or even S1 .= S2 ..
although the latter probably is hiding some ugly copying and
reallocation behind the scenes.
So Perl and PHP use the dot operator like you specify, Python and
JavaScript use addition.
The nice thing about the Python syntax is that it logically leads to the
idea of multiplication being used to repeat strings:
"I say " + 3 * "hello " + "to you all"
evaluates to
'I say hello hello hello to you all'
Yeah, I like PERL a whole lot better than JavaScript.
Except it was never “PERL”, always “Perl”.
PERL has different operators for string compare and numeric compare.
Python manages with the same operator, but because it doesn’t do implicit
conversion between strings and numbers, this reduces the chance for
trouble.
This is why, unlike JavaScript and PHP, Python has no need for a “===”
operator.