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

Implement HaPyLi for WhiteSpace #30

Open
kamil-adam opened this issue Jul 6, 2023 · 0 comments
Open

Implement HaPyLi for WhiteSpace #30

kamil-adam opened this issue Jul 6, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@kamil-adam
Copy link
Contributor

kamil-adam commented Jul 6, 2023

But HaPyLi should look more like Scheme.

Try using scripting style. Like Schema scripts. I know, It is assembler, but try.
The function has number of parameters. But also has size of result.

Types:

  • single value, 0 or 'a
  • pointer to heap, we can load or store it
  • pointer to function, we can call it
  • stack array (vector), for example [0 1 2] or "string"
  • stack pointer, it is possible?

Syntax:

  • parentheses - for call, and many things
  • brackets - for space, arguments and results, for list of variables [a b c d]
  • braces - maybe for list of lines? for (begin first-line second-line) {first-line second-line} ?
  • chevrons - for asm? for (asm first-line second-line) <first-line second-line> ?

We need standard Schema expression:

  • define - for variables, constants and functions. It is eager
  • begin - stupid name, but heh
  • lambda - but without closure, only parameters. It is lazy.
  • if - when, unless. It is lazy.
  • let in - maybe we do need because we have begin-define ?
  • load/import - import file

We need special expression:

  • asm - begin but for assembler code
    • asm has type, how many cells returns, and how many cells gets
    • (asm 2 1 body) gets 2 cells and returns one
  • defines for vectors. defines [a b] = (div-mod 16 3). So define x is shortcut for defines [x]
  • inline vs rec vs macro - which modifier ? It is for optimization

Functions:

  • alloc - first cell of heap is "heap register". Or maybe it can by function? define a = (alloc 4)
  • alloc for arrays and strings

Examples

(define alloc (lambda [n] (asm 
  (ld 0) 
  (cp 1)
  (cp 3)
  (add)
  (st 0)
)))

(define + (lambda [] asm (add)))
@kamil-adam kamil-adam added the enhancement New feature or request label Jul 6, 2023
@kamil-adam kamil-adam pinned this issue Jan 12, 2025
@kamil-adam kamil-adam transferred this issue from helvm/helpa Jan 12, 2025
@kamil-adam kamil-adam pinned this issue Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants