Arc Forumnew | comments | leaders | submitlogin
To Hyphenate or Not to Hyphenate
6 points by proponent 5485 days ago | 3 comments
Some built-in identifier names in Arc, like 'load-table , are hyphenated in classic Lisp style while others, like 'listtable , are not. Is there a pattern to this, something I can use to help me remember names as I learn Arc?


7 points by fallintothis 5485 days ago | link

It'd be interesting if there was a pattern to hyphenated names. I assume there isn't because I just hyphenate when it seems like I "should". i.e., Names are often broken up by hyphens because they're easier to read that way. No real algorithm for that. Things like the length of the name can play a factor (e.g., expand-metafn-call doesn't run together like expandmetafncall). Now that I think of it, that's probably why Common Lisp has so many hyphens: its long names would run together otherwise. Even so, it has butlast, notany, notevery, pushnew, and the p vs -p inconsistency.

Arc tends to avoid hyphens:

  arc> (do1 nil
         (= hyphenated     (keep [find #\- (string _)] (keys sig))
            non-hyphenated (rem  [find #\- (string _)] (keys sig))))
  nil
  arc> (len hyphenated)
  103
  arc> (len non-hyphenated)
  386
  arc> (sort < hyphenated)
  (-- abusive-ip admin-gate admin-page app-path bad-newacct clean-url
  code-block code-density common-operators common-tokens cook-user create-acct
  create-handler date-nums days-since defop-raw defopr-raw disable-acct
  edit-app end-tag english-date english-time enq-limit ensure-dir esc-tags
  expand-metafn-call failed-login fill-table fnid-field gen-type-header
  get-user good-login handle-post handle-request handle-request-1
  handle-request-thread harvest-fnids hello-page hours-since indented-code
  insert-sorted load-table load-tables log-request logfile-name login-form
  login-handler login-page logout-user md-from-form minutes-since n-of
  new-bgthread new-hspace next-parabreak noisy-each parse-date parse-format
  parse-time ppr-call ppr-progn pr-escaped precomputable-tagopt prompt-page
  rand-choice rand-elt rand-key rand-string read-app read-table reassemble-args
  reinsert-sorted rem-app respond-err run-app safe-load-table save-optime
  save-table set-pw single-input space-eaters start-tag static-filetype tag-if
  tag-options text-rows text-type timed-fnid tree-subst unique-id url-for
  user-exists username-taken valid-date vars-form view-app w/link-if
  when-umatch when-umatch/r write-app write-spaced write-table)
Just from this, I see names that work well with hyphens: I can't parse createacct on first glance, hourssince & dayssince are awkward with the two S characters, responderr looks like "responder" with an extra R, pprprogn has too many similar letters jammed together, logfilename could be parsed as either "name of the logfile" or "log the filename", nof is just weird, etc. But there are names that don't strictly need hyphens: I think endtag, filltable, getuser, loadtable, loadtables, randkey, and others look fine, which indicates to me that the issue really is just aesthetic.

-----

1 point by macdice 5465 days ago | link

Also, is there a way to predict/guess/remember which letters to leave out of abbreviated identifier names? No... Consistent hyphenation and abbreviation are what make Scheme look so much nicer than Arc (and Clojure and every other mangled dialect).

-----

1 point by palsecam 5464 days ago | link

Well, fallintothis explained it. There is a scheme: if the name is readable/unambigous w/out hyphens, don't use hyphens, else use some. There are exceptions like 'end-tag to match 'start-tag.

There are some "errors" assuming this scheme is correct, like 'fill-table which could be 'filltable. But Clojure has doto (not do-to) and doall (not do-all) for instance. I don't know Scheme enough, but Common Lisp, as fallintothis pointed it out, also has inconsistencies. I suppose Scheme has some.

-----