[HN Gopher] Common Lisp Wiki: Naming Conventions
___________________________________________________________________
 
Common Lisp Wiki: Naming Conventions
 
Author : susam
Score  : 63 points
Date   : 2022-08-28 14:48 UTC (8 hours ago)
 
web link (www.cliki.net)
w3m dump (www.cliki.net)
 
| djhaskin987 wrote:
| As I've been slowly learning Common Lisp, I'm fascinated by how
| much Rich Hickey took from the CL community in making Clojure.
| For example, the names in embedded languages starting with `?`.
| He uses this naming convention all the time in the datomic
| docs[1] showing how to query the database.
| 
| 1: https://docs.datomic.com/on-prem/query/query.html
 
  | lispm wrote:
  | See for example the Prolog implementation in PAIP:
  | 
  | https://github.com/norvig/paip-lisp/blob/main/docs/chapter11...
  | 
  | But I would think the convention is quite a bit older than
  | Common Lisp and earlier Lisp programs should have used
  | something like that to notate variables in special sublanguages
  | (especially in simple Prolog variants or in Rule-based
  | systems).
 
| wibblewobble124 wrote:
| Scheme also abbreviates:
| 
| call-with-current-continuation
| 
| To
| 
| call/cc
| 
| The forward slash serving the purpose of "with".
 
| nulbyte wrote:
| > These will annoy people: ... hungarian-identifiers-pcsnsi
| 
| What does this mean? I have no idea what pcsnsi is, or why this
| is "Hungarian."
 
  | Jtsummers wrote:
  | It's a reference to Hungarian notation which had two forms,
  | systems and apps. Systems notation would prefix variables with
  | their primitive type:                 long lTime;       bool
  | bPrint;
  | 
  | Apps notation would prefix variables with something conveying a
  | domain-specific semantic element:                 point
  | ptPlayer;
  | 
  | You aren't supposed to know what pcsnsi means because it is
  | just a nonsense string here, but presumably has some potential
  | apps notation meaning if used in the real world.
  | 
  | https://en.wikipedia.org/wiki/Hungarian_notation
 
| uncletaco wrote:
| I am and forever will be a fan of the scheme (and now clojure)
| convention of saying foo->bar to say foo to bar. I just think
| that's swell.
 
  | ruricolist wrote:
  | The CL convention would be to have a function called bar that
  | converts whatever its argument into an instance of bar. Make it
  | generic and new libraries can easily add their own conversions
  | for their own data types.
 
    | lisper wrote:
    | My personal convention is to call such a generic function
    | ->bar to make it clear that what it does is coerce its
    | argument to a different type.
 
  | nemoniac wrote:
  | Actually I'm more of a fan of bar<-foo because you can line
  | them up like:                   (bar<-foo (foo<-baz (baz<-quux
  | thing)))
  | 
  | instead of:                   (foo->bar (baz->foo (quux->baz
  | thing)))
 
  | vats wrote:
  | > I am and forever will be a fan of the scheme (and now
  | clojure) convention of saying foo->bar to say foo to bar. I
  | just think that's swell.
  | 
  | In his book--Lisp in Small Pieces--Christian Quienec suggests
  | using a reversed arrow (ie. bar<-foo) so the direction of the
  | arrow agrees with the evaluation order in a function
  | composition. eg. (foo<-bar (bar<-foo ...)), which would have
  | otherwise been (bar->foo (foo->bar ...)).
 
    | dunefox wrote:
    | That's quite nice.
 
    | mncharity wrote:
    | > bar<-foo
    | 
    | Or bar_from_foo , when identifier charsets prohibit <- .
 
    | nlitened wrote:
    | In Clojure you're likely to use an arrow to do multiple
    | compositions, eg. (-> foo foo->bar bar->baz)
 
| gibsonf1 wrote:
| For predicates, I've abandoned the p postfix as it's then so hard
| to know which predicates you have. Instead we now use the ? as a
| prefix to any Boolean predicate, so in the repl you can just type
| ? Hit tab and see all available predicates.
 
___________________________________________________________________
(page generated 2022-08-28 23:01 UTC)