r/ProgrammingLanguages • Nain. • 1h ago

Would a syntaxless programming language be possible?

So I had the idea of a syntaxless programming language where a function parses its form as it needs.

In this system, a parser is a function turning a description of the syntax to a kind of binding

parser: forms -> (given syntax) -> binding;

For example:

template ([a] is in between [min] and [max]) # binding
  := a >= min and a <= max; # lambda 

Idk just a cool idea. There are many problems with this (for starters, when do you know what parser to use?)

0 Upvotes

20 comments sorted by

View all comments

3

u/alaricsp 1h ago

FORTH has this. A word, when referenced during compilation, can be invoked "immediately" and access the input stream the compiler is compiling and do whatever parsing it wants, then compile code to do whatever needs doing at run time. For instance, the word " parses string literal syntax up to the next ", tucks the string away in memory, and then compiles code to push a pointer to it at run time to the stack, thereby providing string literals!

2

u/NomagnoIsNotDead 7m ago

FORTH has a syntax, it's just turing-complete. Maybe turing-complete syntax doesn't qualify as syntax? That's an interesting question... If the structure can ONLY be correctly inferred from the meaning, is there structure?