-- Leo's gemini proxy

-- Connecting to freeshell.de:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini;lang=en-GB

Stay language suggestion 📢

ew0k suggested some rules for Stay, the antithesis of Go

The presented rules made me think of declarative languages.


The only one I ever used was XSLT, which was conceptually fine, but expressed in XML tags and XPath, which was... not great. The input is some XML on which it does pattern matching, finding templates to apply. It can spit out whatever you want. In my case it was HTML so the whole thing was a forest of angle brackets. This was a long time ago now, and never since have I had a problem that I wanted to solve with XSLT.


I had a colleague who was keen on Prolog. I've never used it, but it seems that you define rules rather than how to apply them, and Prolog figures out what it's going to do.


Maybe Stay could be declarative. A Stay program could define actions to do with input of a certain type. It looks at stdin and does the relevant actions if and when it gets the right kind of input. Here's a rough example (sorting lines of text) with regex-ish matching:

^^  # Matches the beginning of the input
  list lines   # makes a list to put lines in
  string line  # makes a line buffer

\n  # Matches a line break
  lines + line
  string line  # makes another line buffer

$$  # matches the end of the input
  sort lines
  print lines

.  # matches anything not otherwise matched
  line + \1  # add to the current line

I think I'm cheating. I've just assumed that all the relevant primitives exist. If "sort" wasn't already a thing and you had to implement it in this style, how would that be possible? No looping, remember! Maybe we could have rules for processing list elements and a rule for whether we're done. Then the looping is implicit.


As much as I enjoyed thinking about this, I don't want to implement it, or write any software with it.


#programming


back to gemlog

-- Response ended

-- Page fetched on Sat May 4 02:25:21 2024