~andreyorst

Moscow

https://andreyorst.gitlab.io/

I love Lisp and text editors!


#242 fnlfmt - Support additional body forms and macros a month ago

Comment by ~andreyorst on ~technomancy/fennel

Without knowing anything more about those macros, I think it would be appropriate to treat them as having a body?

Are these macros? I don't know. Same for (fn defeat-enemy [...]), meaning that even def* is a bit too broad. for-each may well be a function like map. Yes let-* is unlikely to be a function, but if we're gonna make it such that all fennel body-forming macros have a user-naming pattern, we may incorrectly format a lot of code.

There are a lot of body-forming macros: each, for, when, do, let, while. We can kinda count fn and macro here too.

Then, there are also false positive things like *collect and accumulate don't have bodies, but are still indented like they are. I'd change them to indent body expression with 4 spaces, and in case collect specifically indent two forms with 4 spaces, and the rest with 2, indicating that this is not exactly valid.

def would probably be used in the same scenario as local but local is not indented like bodyform (I changed that in my config to indent local as bodyform though)

What I'm saying here is that it's too broad of a rule to add each-*, for-*, while-*, when-*, do-*, let-* as patterns for something being a macro with a bodyform.

But if we will do only some of them, why don't we do the other too? It'll be weird that this rule applies to some but not the other.

Anyway, these are just thoughts, I'm not against this, but I'll probably will have to do a lot of workarounds in my config if this gets to fennel-mode too to undo some false positives.

#242 fnlfmt - Support additional body forms and macros a month ago

Comment by ~andreyorst on ~technomancy/fennel

Nov 24, 2024 21:32:08 ~technomancy outgoing@sr.ht:

I've been thinking about this some more, and I have another potential solution. What if instead of the rule of with-* and def* being assumed to have a body, we expanded it to any call which has a name that starts with a built-in body-having form? That would make it so let-foo could be indented like let for example.

what about each-other and for-tuna style macros?

-- Andrey Listopadov

#100 ,source REPL command 4 months ago

Comment by ~andreyorst on ~technomancy/fennel

Aug 9, 2024 01:41:11 ~technomancy outgoing@sr.ht:

I was imagining something that worked like clojure.repl/source; in other words something that would use its argument's metadata to open a file on disk and read the source based on the resolved file/line.

I see. Well, In that case I think it's still good to have this feature as a part of the REPL, since the language server is unofficial.

I wasn't proposing that the source for every function ever compiled be saved off in memory.

I wonder if this could be done, as it is more practical since the definition may change at runtime. IIRC there was a branch for source metadata?

#237 How to view infinity 4 months ago

Comment by ~andreyorst on ~technomancy/fennel

removed the math.acos use in the parser, and resent the patch, but the pipeline is failing with a weird error, not sure why.

#237 How to view infinity 4 months ago

Comment by ~andreyorst on ~technomancy/fennel

Figured it out: https://lists.sr.ht/~technomancy/fennel/patches/54487

I am concerned by math.acos however. But there's no way to portably generate strictly positive nan or strictly negative nan as we can't check the sign. Or at least I couldn't find a way.

#237 How to view infinity 4 months ago

Comment by ~andreyorst on ~technomancy/fennel

oh, it does seem that the parser doesn't recognize nan at all even if I add it as I did for inf. I don't get why.

#237 How to view infinity 4 months ago

Comment by ~andreyorst on ~technomancy/fennel

NaN is even weirder. In PUC Lua 5.4 0/0 is -nan, math.abs(0/0) is nan, and -math.abs(0/0) is -nan again. In LuaJIT it is nan, and -math.abs(0/0) is nan again. In Fengari it's the same as LuaJIT, so no negative nan, except it is named NaN.

From https://github.com/gvx/Ser/issues/4

Under Windows, Lua 5.1.5 doesn't seem to generate NaNs, only indeterminates, but it distinguishes both with tostring:

C:\Lua>lua5.1
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> print(to string(math.asin(2)))
-1.#IND
> print(tostring(0/0))
-1.#IND
> print(tostring(-(0/0)))
1.#QNAN
>

I'm not comparing strings, of course, but I kinda wonder how it should all work.

#237 How to view infinity 4 months ago

Comment by ~andreyorst on ~technomancy/fennel

also, maybe we should also support NaN in the same way? Encoding is ridiculous though: (+ (/ 1 0) (/ -1 0)). Right now you can't read back nan from view.

#237 How to view infinity 4 months ago

Comment by ~andreyorst on ~technomancy/fennel

~technomancy, WDYT should it be: &-inf or -&inf ? -&inf makes more sense, although it's a bit weird?

#237 How to view infinity 4 months ago

~andreyorst assigned ~andreyorst to #237 on ~technomancy/fennel