Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for Cognate words?? #19

Open
dragoncoder047 opened this issue Oct 27, 2022 · 8 comments
Open

Documentation for Cognate words?? #19

dragoncoder047 opened this issue Oct 27, 2022 · 8 comments

Comments

@dragoncoder047
Copy link
Contributor

There isn't any documentation on each builtin word, and so for the ones that take and/or return blocks, the semantics are very confusing. Case in particular. What are the semantics of that, and everything else? Writing it as Forth stack-effect diagrams or just some example code would help.

@shreder95ua
Copy link

i can try to help with documentation, if only the admins will want to

@StavromulaBeta
Copy link
Collaborator

I'm currently at university so I'm a tad busy, but I'll be able to write some more documentation once the term finishes - as well as actually finish the compiler rewrite!

@StavromulaBeta
Copy link
Collaborator

Also, the behaviour of some combinators such as Case might change in future, as the current iteration is very difficult to optimise and can be a bit confusing.

@dragoncoder047
Copy link
Contributor Author

I might use the "old" (i.e. current) behavior of Case in TEHSSL, because then you don't have to write ( ) around a function that is comprised entirely of a large Case switch.

@StavromulaBeta
Copy link
Collaborator

StavromulaBeta commented Oct 29, 2022

Well that part of the behavior I'm keeping. The bit I'm concerned about is the fact that you can do this, maxing blocks and value types.

Def F as
   Case 1 is 2
   Case (> 3) is (+ 1)
   Case -1 is (+ 3)
   otherwise 5;

The problem with this being that it has to do dynamic dispatch on the type passed to it, and it's very difficult to generate good code from this.

@StavromulaBeta
Copy link
Collaborator

Well that part of the behavior I'm keeping. The but I'm concerned about is the fact that you can do this, maxing blocks and value types.

Def F as
   Case 1 is 2
   Case (> 3) is (+ 1)
   Case -1 is (+ 3)
   otherwise 5;

The problem with this being that it has to do dynamic dispatch on the type passed to it, and it's very difficult to generate good code from this.

Perhaps a better solution would be to have variants of Case that take differing combinations of blocks and values.

@StavromulaBeta
Copy link
Collaborator

StavromulaBeta commented Oct 29, 2022

This is uglier but generates much better code, since types are more deterministic:

Def F as
   Case (== 2) then (3 Drop)
   Case (> 3) then (+ 1)
   Case (== -1) then (+ 3)
   otherwise (5 Drop);

@StavromulaBeta
Copy link
Collaborator

Unfortunately I can't find any other languages that implement anything like the Case combinator here (closest is probably Factor) so I haven't got much to work with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants