21 Apr 2024 |
scrawl | In reply to @_discord_870115701279584326:t2bot.io Thanks. I’ve built a bunch of these but wasn’t sure what the “M tokenizer” was. are they publicly available? | 10:41:56 |
scrawl | In reply to @_discord_1140710589165994105:t2bot.io discodoug here's an animation of the tokenizer: ktye.github.io/kweb/tok.html nice | 10:42:58 |
discodoug | Mostly somewhere on my [github[(https://github.com/gitonthescene/ngnk-lsp/blob/main/k/semantic.k). | 10:43:38 |
discodoug | * Mostly somewhere on my [github](https://github.com/gitonthescene/ngnk-lsp/blob/main/k/semantic.k). | 10:43:50 |
discodoug | I copied the basic form from stuff on nsl.com | 10:44:42 |
22 Apr 2024 |
| jenny joined the room. | 03:22:44 |
alexshroyer | Based on dzaima (discord) 's suggestions, my parser is a little different from ngn/k but I think it's usable. Here are some of the trickier test cases that now pass:
a+ ⇒ (prj + a)
+- ⇒ (cmp + (prj -))
(+)- ⇒ (prj - +)
+(-) ⇒ (+ -)
a+- ⇒ (cmp (prj + a) (prj -))
*a+- ⇒ (cmp * (cmp (prj + a) (prj -)))
+-* ⇒ (cmp + (cmp - (prj *))) | 16:52:06 |
alexshroyer | One more:
(a+)- ⇒ (prj - (prj + a)) | 16:53:51 |
alexshroyer | Ugh, now I have f[x]y parsing like f([x]y) but I think it should be (f[x])y . | 17:32:02 |
dzaima | […] is somewhat like an adverb, except the result is a noun instead of a verb | 17:38:37 |
dzaima | * x[…] is somewhat like an adverb, except the result is a noun instead of a verb | 17:38:48 |
alexshroyer | Makes sense. | 17:57:58 |
23 Apr 2024 |
chrispsn | What’s a good syntax for defining function inverses? | 13:14:49 |
chrispsn | Specifically thinking of format de-serialisation | 13:16:58 |
alexshroyer | I like the idea of filling holes in the current syntax as much as possible
f:{regular}:{inverse}
f:{regular}
{f}:{inverse}
As for calling the inverse of f, that seems trickier. Maybe just a special "call the inverse of f" function like inv[f][args] . Or maybe add a unary adverb overload like ':f x . | 14:44:33 |
chrispsn | In reply to @_discord_595317473247756288:t2bot.io I like the idea of filling holes in the current syntax as much as possible
f:{regular}:{inverse}
f:{regular}
{f}:{inverse}
As for calling the inverse of f, that seems trickier. Maybe just a special "call the inverse of f" function like inv[f][args] . Or maybe add a unary adverb overload like ':f x . assigning to a primitive/composition/lambda is an interesting idea | 15:10:01 |
chrispsn | i don't think there'd be a conflict with ngn/k's "use unicode chars as verbs" feature | 15:11:18 |
chrispsn | hmm, on second thoughts, maybe it would. unless it's a composition | 15:11:59 |
chrispsn | In reply to @_discord_595317473247756288:t2bot.io I like the idea of filling holes in the current syntax as much as possible
f:{regular}:{inverse}
f:{regular}
{f}:{inverse}
As for calling the inverse of f, that seems trickier. Maybe just a special "call the inverse of f" function like inv[f][args] . Or maybe add a unary adverb overload like ':f x . calling inverse would be done as: (f)? | 15:12:44 |
chrispsn | like it is for `j? etc | 15:13:57 |
alexshroyer | Taking more inspiration from J's "assign obverse/adverse":
f:{a}:{b} /f is a, f inverse is b
f:{a}::{b} /try a, if it errors, call b | 15:38:19 |
alexshroyer | I should note that currently this is already used in ngn/k: f:{a}:{b} just assigns f to {b} . | 15:40:19 |
dzaima | fun: f (:) 3 returns 3 and doesn't error, even if f doesn't exist, and it does not assign to f either | 15:45:43 |
alexshroyer | f(:regular;inverse;except) | 15:54:11 |
anaseto | In reply to @dzaima:matrix.org fun: f (:) 3 returns 3 and doesn't error, even if f doesn't exist, and it does not assign to f either Yeah, ngn/k's parsing of : is a bit surprising, parens usually nominalize, so one would expect (:) to always be "right", but for some reason parens around : disappear during parsing if there's something on the right. | 16:45:11 |
anaseto | It's parsed as f (: 3) . | 16:46:32 |
dzaima | ah, and that's a "return" | 17:23:04 |
discodoug | That feels like a bug to me. Not that I have a suggested fix… | 21:43:25 |
coltim | f (::) 3 also feels wrong | 22:09:28 |
ovf | to make users of ngn/k feel better, k4 has a related parser quirk: (:;`a)~-5!"()a" (-5! is parse) | 22:17:50 |