Olical / aniseed

Neovim configuration and plugins in Fennel (Lisp compiled to Lua)
https://discord.gg/wXAMr8F
The Unlicense
610 stars 28 forks source link

Is it possible to refer :all like in clojure require? #115

Closed D00mch closed 2 years ago

D00mch commented 2 years ago

Can't find it in docs or other issues.

Start thinking of making macroses that use aniseed.core under the hood to be able to call functions like assoc directyly, without prefix (c.assoc).

P.S. Example, which doesn't work :)

 :assoc
 (fn [...]
   `(let [c# (require aniseed.core)]
     (c#.assoc ,...)))
Olical commented 2 years ago

Not yet, that doesn't exist, nor do I ever ever like using it or seeing it 😅 it's been pushed out of mainstream Clojure use for a reason, it's horribly hard to understand in most cases, some are okay (maybe core?... maybe at a push...) but people start to misuse it can cause all sorts of namespace soup.

If you REALLY want this, then a function or macro could be created that does it (I don't know how it'd work, it requires introducing many things into the global scope, that seems hard at compile time, if not impossible) which you'd put under _G.require-all for example.

Then in the module macro you could use (module foo {require-all [my-module-name]}) which would call your function for you since the module macro passes through to some global function to handle the names.

Olical commented 2 years ago

My point is, I would prefer this to be a kind of 3rd party / user custom thing since I don't like promoting things that splat everything into a namespace / context, I think it proliferates namespace soup where nobody knows where anything came from, personally.

I also don't know how it'd be implemented, it seems really, really hard to get right.

D00mch commented 2 years ago

Ok, I will just use c.assoc without remorse :)

Olical commented 2 years ago

I will however recommend that you can do this now:

(module foo
  {require {{: assoc} aniseed.core}})

(assoc ...)

So we can maybe meet in the middle! It's the splatting of EVERY unknown thing into a context that's always unsettled me. Especially when people use it in documentation and I can't tell what the example is referring to and which module it came from.

D00mch commented 2 years ago

yes, that's even better, I didn't know I could do this.

D00mch commented 2 years ago

It works, but I cant evaluate it in place.

unexpected multi symbol table: 0x010637f280

(module plugin.sandwich
^^^^^^^^^^^^^^^^^^^^^^^
* Try removing periods or colons from table: 0x010637f280.
(module plugin.sandwich
  {require {nvim aniseed.nvim
            u util
            {: str : assoc} aniseed.core}})
Olical commented 2 years ago

Hm, yeah, I can reproduce, will look into it

Olical commented 2 years ago

Spent my lunch break on it but I think it's fixed now! Pretty tricky stuff to get right since now I have Fennel symbols in some places and tables in other places. So I have to guard against those types and behave differently at various layers.

Olical commented 2 years ago

I only added it this weekend and haven't had a chance to document it other than tweeting it so far :D

On Mon, 25 Apr 2022 at 10:42, Artur Dumchev @.***> wrote:

yes, that's even better, I didn't know I could do this.

— Reply to this email directly, view it on GitHub https://github.com/Olical/aniseed/issues/115#issuecomment-1108334288, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACM6XJF2D4XOKF4RILZZI3VGZSGPANCNFSM5UGPAC3Q . You are receiving this because you commented.Message ID: @.***>