[HN Gopher] Emacs Lisp shorthands as namespacing system
       ___________________________________________________________________
        
       Emacs Lisp shorthands as namespacing system
        
       Author : gjvc
       Score  : 78 points
       Date   : 2022-11-27 19:18 UTC (9 hours ago)
        
 (HTM) web link (andreyorst.gitlab.io)
 (TXT) w3m dump (andreyorst.gitlab.io)
        
       | georgeoliver wrote:
       | I'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_na...
       | 
       | https://news.ycombinator.com/item?id=2580383
       | 
       | (The OP is a very well written article btw, nice work!)
        
       | ahungry wrote:
       | I've been using https://github.com/Malabarba/Nameless for awhile
       | now - it's functionally very similar to the new Emacs shorthands
       | feature.
        
       | nonrandomstring wrote:
       | For 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.
        
         | nerdponx wrote:
         | This 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 wrote:
         | I prefer JavaScript's idiomatic approach:
         | import anyNamespace from 'module.js'       import { subModule }
         | from 'module.js'       import { subModule as anyName } from
         | 'module.js'
        
           | rtpg wrote:
           | the 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!)
        
         | nequo wrote:
         | Python really got that right. In Haskell, it's similar:
         | import qualified Foo.Bar as Baz
        
         | smcl wrote:
         | Importing a namespace under an alias exists in a few languages
        
       | sureglymop wrote:
       | Somewhat 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.
        
         | gjvc wrote:
         | This tool https://www.wappalyzer.com/ will tell you.
        
         | the-smug-one wrote:
         | Right-click -> Show source
        
         | CharlesW wrote:
         | https://andreyorst.gitlab.io/posts/2022-02-22-new-look/
         | 
         | TLDR: Hugo + Rocinante theme (https://github.com/mavidser/hugo-
         | rocinante)
        
           | sureglymop wrote:
           | Thank you a lot, exactly what I wanted to know :)
        
       | nerdponx wrote:
       | I 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 wrote:
         | I 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.
        
       ___________________________________________________________________
       (page generated 2022-11-28 05:00 UTC)