Skip to main content


Hey #forth people, does the stack effect spacer in word definitions have a name?
Unknown parent

Devine Lu Linvega
@vertigo but it's more than a dash.. it's two dashes!
Unknown parent

Devine Lu Linvega
@oppen yeah, I think I know which one you mean, I've seen the vertical one before, never seen an em dash with a space tho
Unknown parent

Görllewin
or was that just a vertical pipe with a gap from the BBC Micro I'm remembering? ...
Unknown parent

Devine Lu Linvega
@oppen never seen this 0_o I don't think that was in the BBC Micro tho
in reply to Devine Lu Linvega

whoa, am i seeing some sort of type checker based on the stack effect comment being written here?
in reply to Karol Belina

@karolbelina YES! wow, you're sharp. It's exactly that, I am type checking pure functions
in reply to Devine Lu Linvega

@karolbelina awesome! this has been on my list for a long time. some cool possibilities!
in reply to ⛧ esoterik ⛧

@d6 @karolbelina I was trying to find prior art for this with others concatenative languages, if you have seen this in the wild I'd love to read about it!

I was wondering if either of you have the patience/tooling to generate a balance table for each opcode? I need a 256 bytes page where each byte is hb: input, lb: output. :flonshed:
in reply to Devine Lu Linvega

@d6 @karolbelina can you describe the format of the table in more detail? I don't quite understand.

I'm interested because of the Beetlang concept: https://melanocarpa.lesarbr.es/hypha/beetlang
in reply to bouncepaw 🍄

@bouncepaw @d6 @karolbelina it would need to be a binary table made of shorts for each opcode corresponding to the opcode hex value. The high byte would be for RST effect, the low byte for WST effect, and each high nibble input, and each low nibble output.

http://wiki.xxiivv.com/site/uxntal_reference.html

For example:

ADD 0021
ADD2 0042
ADD2k 0046
ADD2r 4200
in reply to Devine Lu Linvega

@bouncepaw @d6 @karolbelina Actually, it would be better if RST was in the low-byte so I can use the flag to increment the position by one.

0xffff
[ WST input nibble ] [ WST output nibble ] [ RST input nibble ] [ RST output nibble ]
in reply to Devine Lu Linvega

@d6 so like, each byte is the corresponding opcode, which consists of high nibble and low nibble (0bHHHHLLLL), and each nibble can encode the stack "state", so like 0 is empty stack, 1 is stack with one byte, 2 is stack with one short, 3 is stack with byte and short (or short and byte) and so on?
in reply to WimⓂ️

@wim_v12e @karolbelina @d6 Like this: https://merveilles.town/web/@neauoire/109553230734004721
in reply to Devine Lu Linvega

@karolbelina @d6 I understand what the values are you want the generate, but what form should this take? a text file file with hex notation so you can include it into any Uxntal program, or a binary file with just the bytes?
in reply to Devine Lu Linvega

@wim_v12e @karolbelina i'm at work now but i may be able to use the table i created for uxntal-mode to generate this:

https://github.com/non/uxntal-mode/blob/main/uxntal-mode.el#L225

(it's used to provide an interactive command to show the stack effect for any instruction with any combination of 2kr).
in reply to Devine Lu Linvega

@d6 @karolbelina As soon as I woke up this morning I realised that wasn't quite right. Messed up the shifts. Hopefully fixed now. It's now properly sorted as well.
in reply to Devine Lu Linvega

:: If you are looking for prior art in statically checked stack based languages there is Kitten and Cat. Also, Factor implements stack checking for input and output effects to match, but it is dynamically typed. I've been told Joy does stack checking, but I'm not certain.
in reply to Devine Lu Linvega

@CapitalEx here is cat, in case you hadn't found it yet: https://github.com/cdiggins/cat-language

I'm pretty sure I saw another typed stack language inspired by both cat and kitten somewhere not too long ago but my bookmarks fail me.
in reply to Job

@vanderZwan @CapitalEx I had found it, but thanks, maybe someone reading this might appreciate the link too 😀
in reply to Devine Lu Linvega

:: I figured you already hear of them. I'm very much looking forward to your work in this area. Not many active projects exploring it these days.
in reply to Devine Lu Linvega

@d6 i'm on a train rn so these should really be double checked, also they need some multiple cursor action to merge them into one table and i don't have a proper editor on my phone lol https://gist.githubusercontent.com/karolbelina/5ebec5878bcc3b81ea3783dbc1b6b37c/raw/196b08d8466bce52d218cf41257ff57bde4c0aae/uxnbal_tables.txt
in reply to Devine Lu Linvega

THATS SO GOOD

hah, i noticed that only because i was doodling with an uxntal type checker lately. no code yet, just some ideas on paper (might share those soon)

unfortunately i was stumped by some things regarding the implementation in my head. i'm so happy you're working on that kind of thing, would be a great addition to the ecosystem. love the name too. balancing the stack!
Unknown parent

spooky blip 👻
@tty I dont think Devine is likely to dive into type systems but I'd totally borrow this term for gluumy, I love it
Unknown parent

Devine Lu Linvega
@klardotsh @tty I'm just not sure if type checking is the right word for this, it's more like stack balancing.
Unknown parent

Devine Lu Linvega
@klardotsh @tty every opcode's stack effect is predictable, so a pure function without branching:

@function ( a* b -- c )
ADD ADD
JMP2r

My balancer knows that the stack should be 2 items less then when coming in, I can run through each opcode and get the expected offset, if the balance planned, and the balance actual don't match, then I throw a warning.
Unknown parent

Devine Lu Linvega
@klardotsh Oh! Arity is a good similar concept, thanks 😀

Lo, thar be cookies on this site to keep track of your login. By clicking 'okay', you are CONSENTING to this.