Re: [m-users.] String comparison when compiling to C
"Sean Charles (emacstheviking)" <[email protected]> Sat, 24 Aug 2024 09:44:40 +0100
| Newsgroups | gmane.comp.lang.mercury.general |
|---|---|
| Message-ID | <[email protected]> |
>
> Given that background, I will be *fascinated* to see what a strongly
> typed Forth looks like.
Me too :D
The general idea is that instead of one stack per type (nightmarish), a single data stack holds all the guff as it happens, then, I have mulled over either:
1. Reworking "{" and "}" so that you have to specify the types, eg { val1:int val2:str } sort of thing
OR
2. Introduce a word, SIGNATURE (or SIG) so that you can specify the type signature i.e the stack expectation when the word gets called, it will then, using (1) above as the example,
"int uint8 str" SIGNATURE [WordName]
* ensure there are two items on the stack
* ensure the types are as expected
Something like that, for now I am just getting the basics down, I've done IF/ELSE/THEN(ENDIF), DO...LOOP to see how control words pan out, nicely, as it happens. As I am not a real CPU, the internal representation of a word is a tree containing the various VM opcodes, so an if then is
if_then(VmTrue, VmFalse)
so, if TOS is 'true' I execute the first code block, else the second.
Yes, I can't wait to see what it looks like either, I might be tempted to make a YT video? Been putting it off for years...
Sean.
_______________________________________________
users mailing list
[email protected]
https://lists.mercurylang.org/listinfo/users