Deutsch   English   Français   Italiano  
<vqc04s$2utf6$1@dont-email.me>

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

Path: ...!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: bart <bc@freeuk.com>
Newsgroups: comp.lang.c
Subject: Re: Python recompile
Date: Thu, 6 Mar 2025 11:15:39 +0000
Organization: A noiseless patient Spider
Lines: 115
Message-ID: <vqc04s$2utf6$1@dont-email.me>
References: <vq1qas$j22$1@gallifrey.nk.ca> <vq1uvb$qbuq$1@dont-email.me>
 <vq22nc$rvb8$1@dont-email.me> <vq24kd$rg6i$1@dont-email.me>
 <vq3oag$18iv6$1@dont-email.me> <vq4hf2$1brf7$1@dont-email.me>
 <vq4l3d$1ck9e$1@dont-email.me> <vq4m0u$1ctpn$1@dont-email.me>
 <vq4n05$1d5dv$1@dont-email.me> <vq4om7$1dbo2$2@dont-email.me>
 <vq6dqh$1pskk$1@dont-email.me> <vq6f8p$1pmnk$1@dont-email.me>
 <vq6gqc$1qcp8$1@dont-email.me> <vq6ips$1pmnk$2@dont-email.me>
 <vq6j5h$1qosf$1@dont-email.me> <20250304092827.708@kylheku.com>
 <vq7g1p$1vmg5$1@dont-email.me> <vq8544$23f55$4@dont-email.me>
 <vq88s7$242vk$1@dont-email.me> <vq8cdq$24hi9$2@dont-email.me>
 <vq9di0$2db82$1@dont-email.me> <vqb18d$2mem7$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 06 Mar 2025 12:15:40 +0100 (CET)
Injection-Info: dont-email.me; posting-host="fd83b2795c6da370cc681229f8db3e15";
	logging-data="3110374"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+dFBmQvc9LHRqDFuWdd8sq"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:mFYfOCuyPP9pEyvA/J/0naNL4w8=
In-Reply-To: <vqb18d$2mem7$2@dont-email.me>
Content-Language: en-GB
Bytes: 6064

On 06/03/2025 02:28, Lawrence D'Oliveiro wrote:
> On Wed, 5 Mar 2025 11:46:08 +0000, bart wrote:
> 
>> * Compile-time enumerations, and parallel tables of enums and data
> 
> Python doesn’t have enumerations as a language primitive; instead, they
> are implemented in a library module, written in pure Python -- it doesn’t
> do anything you can’t do in your own code. But it supports arbitrary
> attributes attached to enum instances, and subclassing of enums.
> 
>> * Jump-table-based 'switch' (this requires those named consts or enums)
> 
> Does it do switched expressions? You can do those in Python.

Do you mean 'match case'? This was recently added after some 30 years. 
But when I tested it, it wasn't significantly faster than an if-elseif 
chain.

The point of a jump-table-based switch is to do all tests 
simultaneously, rather than sequentially, which is a big advantage for 
interpreted code.

And for that to be possible when the switch values are names (such as 
enumeration codes) requires those values to be known to the bytecode 
compiler. (Switch values that are integer constants only are not practical.)

In Python they are not known until runtime, but even then, they can 
change and so could be different each time the switch is encountered.

In Python *every identifier is a variable*, one which can be assigned a 
new value at any time, even if some variable values are immutable. That 
means you can't modify the value that A currently holds, but you can 
replace the whole thing.

With my language, it is known at compile-time whether any top-level 
identifier is a function, module, type, record, variable, named 
constant, imported function, macro or label.

If I wanted to do the equivalent of this:

    def F(): return "hi"
    ....
    F = 42

then I'd have to write it as:

    fun G = "hi"
    F := G
    ....
    F := 42

Here, F is a variable name; G is a function name.

>> * Character constants: 'A' and 'ABCDEFGH' (Python needs 'ord("A")')
> 
> Python also has “\u” and “\U” for Unicode.

I have this:

   println "\u20AC"         # string (shows €)
   println '\u20AC'         # integer
   println '\u20AC':"m"     # shows € (interpret as multibyte char)

With \v used for 6-digit hex codes. But the encoding with these is UTF8, 
so this is stored as a 3-byte sequence, or taking up 24 bits of an integer.

>> * Built-in maths functions and constants like 'pi'
> 
> Complex arithmetic? <https://docs.python.org/3/library/cmath.html>
> 
> Hyperbolic functions? Gamma/log-gamma?
> <https://docs.python.org/3/library/math.html>
> 
> There’s a reason why we don’t want to build all these into the core
> language, since there are so many of them that are needed nowadays.

Are they? I find I only need the basics! I don't think the 'hyp' button 
on my Casio has ever been pressed (I've only just noticed it).

Actually, my language started off as a DSL for my 3D graphics apps so it 
had a lot of special purpose types built-in. So if p and q were 3D 
points, m was a transformation matrix, and e/f were edges (lines, arcs, 
circles) then:

     (p + q)/2          # was the midpoint of pq
     m * p              # transformed the point p
     intersect(e, f)    # return points of interesections of e and f

Yes, Python has acquired 1000s of libraries because of the number of 
people who used it or develop stuff for it. It's an industrial scale 
product.

I'm not competing with that. Mine is a personal tool.

>> * Expression-based macros
> 
> Really only necessary if your language is not dynamic enough.
> 
> I notice no mention of coroutines or iterators. Those are quite useful
> nowadays.

I've played around with closures, generators and iterators. I decided 
they were too clunky in my implementation and a poor fit for my product 
and style of coding.

But regarding closures, there is a famous test 'man or boy' which relies 
heavily on them (https://en.wikipedia.org/wiki/Man_or_boy_test).

I tested the Python 3 code from Rosetta Code, set up to print the 
results for k=0 to 20 inclusive.

Python 3.14 took 10 seconds. I emulated what was needed in my language, 
and it took 0.8 seconds. (PyPy crashed at k=16, but the timing up to 
k=15 suggested it was a little faster than CPython.)