mhkeller/nodebooks

Shorter `display` call & module naming convention

Closed this issue · 2 comments

In thinking about other modules and desired usage, it would be less verbose if they were their own function calls. This brings up the issue, though, of hooking onto display for [all sorts](https://github.com/mhkeller/nodebooks/blob/ast/nodebooks.js#L44 https://github.com/mhkeller) of things

One idea is we use a symbol, such as ρ. Basic usage would be

var data = [{name: 'mhk', location: 'NY'}]

ρ(data)

// Prints  [{name: 'mhk', location: 'NY'}]

If you wanted a different format you would do

ρTable(data)

// Prints a formatted table

Perhaps it could do

node.callee.name.match(/^ρ/)

where it's currently looking for display.

Any modules could extend context with what they want, such as ρTable.

Drawbacks

These greek characters are hard to type. It would be great if we could use a more standard symbol like @ but JavaScript doesn't like it. Also I think it would look nicer if it were an uppercase character so you wouldn't have to enforce "the first character must be uppercase" to ensure legibility. I wasn't too taken by any of the uppercase ones, though. Maybe Φ. Too bad we can't use » or something that makes more semantic sense. Σ is not bad because it's kind of like "equals" but it might be too "mathy" and turn people away.

One suggestion is __ which has nice aesthetics. One possible con is if it's confused with more system level variables like __dirname but jury suggests not.

Use __ for now 2f3f0ef