Skip to content

Implement HaPyLi for WhiteSpace #30

Open
@kamil-adam

Description

@kamil-adam

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)))

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions