Liste des Groupes | Revenir à cl c |
On 08/09/2024 19:13, Waldek Hebisch wrote:Bart <bc@freeuk.com> wrote:On 08/09/2024 01:05, Waldek Hebisch wrote:Bart <bc@freeuk.com> wrote:>>Then you no longer have a language which can be implemented in a few KB.>
You might as well use a real with with proper data types, and not have
the stack exposed in the language. Forth code can be very cryptic
because of that.
First, it is not my goal to advocate for Forth use.
You're doing a fine job of it!
>
For me it's one of those languages, like Brainf*ck, which is trivial to
implement (I've done both), but next to impossible to code in.
I wonder if you really implemented Forth. Did you implement immediate
words? POSTPONE?
I implemented a toy version, with 35 predefined words, that was enough
to implement Fizz Buzz. Then I looked for more examples to try and found
they all assumed slightly different sets of built-ins.
define fibr(n);
if n < 2 then 1 else fibr(n - 1) + fibr(n - 2) endif
enddefine;There are some anomalies, assignment is written as:
>
a -> b;
>
which means assign a to b.
This POP11 seems a more viable language than Forth. (I vaguely remember
something from college days, but that might have been POP2.)
external declare tse in oldc;
void
tse1(da, ia, sa, dp, ip, sp, d, i, s)
double da[];
int ia[];
float sa[];
double * dp;
int * ip;
float * sp;
double d;
int i;
float s;
{
}
endexternal;
The first line switches on syntax extention and lines after that
up to 'endexternal' are parsed as C code. More procisely, 'oldc'
expects KR style function definitions (with empty body). As
result this piece of code generates Pop11 wrapper that call
corresponding C routine passing it arguments of types specified
in C definition (but on Pop11 side 'double da[]' and 'double * dp'
are treated differently). Note that this in _not_ a feature of
core Pop11 langrage. Rather it is handled by library code (which
in principle could by written by ordinary user.
I don't quite understand that. Who or what is the C syntax for?
Does POP11 transpile to C?
Usually the FFI of a language uses bindings expressed in that language,
and is needed for the implementation to generate the correct code. So
it's not clear if calls to that function are checked for numbers and
types of arguments.
Pop11 has very similar semantics to Lisp and resonably traditional
syntax. I would say that Lisp users value more extensibility than
traditional syntax. Namely Lisp macros give powerful extensibility
and they work naturaly with prefix syntax. In particular, to do
an extension you specify tree transformation, that is transformation
of Lisp "lists", which can be done conveniently in Lisp. In Pop11
extentions usually involve some hooks into parser and one need to
think how parsing work. And one needs to generate representation
at lower level. So extending Pop11 usualy is more work than extending
Lisp. I also use a language called Boot, you will not like it
because it uses whitespace to denote blocks. Semantics of Boot is
essentially the same as Lisp and systax (expect for whitespace)
is Algol-like.
One of yours? A search for Boot PL didn't show anything relevant.
One of my early program did recursive walk on a graph. Goal was
to do some circuit computation. I did it in Basic on ZX 81.
I used GOSUB to do recursive calls, but had to simulate the argument
stack with arrays. This led to severl compilcations, purely
because of inadequacy of the language.
On ZX81? I can imagine it being hard! (Someone wanted me to do something
on ZX80, but I turned it down. I considered it too much of a toy.)
Les messages affichés proviennent d'usenet.