4 ms·
Emacs Lisp shorthands as namespacing system
- nonrandomstring 4y agoFor me, Python's "from library import module as myname" is unbeatable. I like to choose my own namespaces and assign whatever bits of a lib to it as I feel like. It seems robust and flexible.
- smcl 4y agoImporting a namespace under an alias exists in a few languages
- nerdponx 4y agoThis usage is so idiomatic and ubiquitous that you can see "np." or "pd." or "plt." in just about any code and assume that the user is using Numpy or Pandas or Matplotlib. Now that I think about it, I really should set up a "snippet" to type this for me: import matplotlib.pyplot as plt import numpy as np import pandas as pd
- soulofmischief 4y agoI prefer JavaScript's idiomatic approach: import anyNamespace from 'module.js' import { subModule } from 'module.js' import { subModule as anyName } from 'module.js'
- rtpg 4y agothe biggest problem with JS's is extremely incidental, but a total mess in practice. If you type from left to right it's impossible for auto-complete to help you with member names (since it can't know what module you're looking for!)
- soulofmischief 4y agoI work around this in two ways: A) I type "import {} from 'module" first and then go back and add modules or more often these days, B) I let Copilot guess for me, which combined with my predictable file organization usually results in the right autocomplete. Option A can be improved upon by writing a macro/template with slots in the correct order.
- nequo 4y agoPython really got that right. In Haskell, it’s similar: import qualified Foo.Bar as Baz
- tmtvl 4y agoDoes Python allow import symbol renaming? In R6RS Scheme I can do the following: (import (prefix (rename #;from (rnrs r5rs) (delay #;as eval-later) (force #;as eval-now)) r5rs:)) And from (rnrs r5rs) it will import delay as r5rs:eval-later and force as r5rs:eval-now.
- nerdponx 4y agoI don't like the conflation of "-" as both "word separator in the name" and "namespace". I prefer keeping the "/", so you would get "snu/lines" instead of "some-nice-string-utils/lines". Otherwise I think this article is great, and I don't see why more languages don't use this kind of system, instead of dumping all symbols in the imported namespace into the current namespace.
- sillysaurusx 4y agoI went back and forth on this. Using / has one major disadvantage. You can’t name macros w/stdin, w/stdout, w/file, etc. It’s short for “with-“. It’s only a few characters, but it adds up. Admittedly it’s more important in arc, where brevity is a feature, not a bug. On the other hand, having a full separator for the namespace is worthwhile. One idea I toyed with is: my-func@pkg So the namespace is on the right, not the left. But I decided this is even worse, even if it does match e.g. how we ssh into things. Ultimately it’s hard to beat a global namespace with prefixing conventions.
- ahungry 4y agoI've been using https://github.com/Malabarba/Nameless https://github.com/Malabarba/Nameless for awhile now - it's functionally very similar to the new Emacs shorthands feature.
- sureglymop 4y agoSomewhat unrelated but does anyone know how this website was made? I like the layout and have been wanting to start a blog for some time, this looks perfect.
- the-smug-one 4y agoRight-click -> Show source
- CharlesW 4y agohttps://andreyorst.gitlab.io/posts/2022-02-22-new-look/ https://andreyorst.gitlab.io/posts/2022-02-22-new-look/ TLDR: Hugo + Rocinante theme (https://github.com/mavidser/hugo-rocinante https://github.com/mavidser/hugo-rocinante)
- sureglymop 4y agoThank you a lot, exactly what I wanted to know :)
- gjvc 4y agoThis tool https://www.wappalyzer.com/ https://www.wappalyzer.com/ will tell you.
- LanternLight83 4y agoWon't tell you anything about the static site generator they use, or much else about the HTMl that's returned was made, even what program spit it out-- the information usually just isn't there :p They've got a post on their workflow here: https://andreyorst.gitlab.io/posts/2022-10-16-my-blogging-setup-with-emacs-and-org-mode/ https://andreyorst.gitlab.io/posts/2022-10-16-my-blogging-se...
- gjvc 4y agoYes, I expected to be corrected on this. Thank you.
- georgeoliver 4y agoI'm surprised Unison's approach hasn't caught on more widely. ISTR Joe Armstrong of Erlang was experimenting with something similar in a related domain, https://joearms.github.io/published/2015-03-12-The_web_of_names.html https://joearms.github.io/published/2015-03-12-The_web_of_na... https://news.ycombinator.com/item?id=2580383 https://news.ycombinator.com/item?id=2580383 (The OP is a very well written article btw, nice work!)
- gjadi 4y agoIf you want to learn about CL packages and namespaces (namespaces are not packages). Take a look at https://gigamonkeys.com/book/programming-in-the-large-packages-and-symbols.html https://gigamonkeys.com/book/programming-in-the-large-packag...
- lispm 4y agoBy now they (some maintainers and some users) have a lot from a typical Common Lisp into Emacs Lisp re-engineered (incl. the Common Lisp Object System), but it is not 'officially allowed' to actually upgrade the language/runtime to it. Just libraries or forks...