TodePond / DreamBerd

perfect programming language
https://dreamberd.computer
Other
10.62k stars 299 forks source link

[RFC] Macro & Marco support #642

Open someone13574 opened 2 weeks ago

someone13574 commented 2 weeks ago

Macro support

Macro support would be nice. I suggest using brainfuck for macros, as it only consists of a few primitives, so it will be easy to learn. Macros are added to the top of the file and modify the source code. To allow self-modifying macros, each one is repeatedly run in order until a full pass of all the macros is made without changing anything.

As this has the potential for infinite loops, I suggest adding a halting problem solver which detects whether the compiler will get stuck in an infinite loop. If it thinks it will get stuck, it will irreversibly delete the source code to prevent you from accidentally bricking your computer.

Note: const const const const const cannot be modified by macros.

Marco support

In addition to macro support, there should be Marco support. This would be an alternative runtime which is evaluated by the nearest Marco. If the he is already evaluating a program, the two programs are timeshared, but can access each others variables (sometimes; only if his memory is bad). This can also support running on multiple Marco’s if performance is needed.