Pairs of identifiers
From HaskellWiki
(Difference between revisions)
(HaskellWiki syntax highlighting, Table) |
m (→Del) |
||
| (5 intermediate revisions not shown.) | |||
| Line 77: | Line 77: | ||
|} | |} | ||
| - | = Discussion = | + | == Discussion == |
| - | == read and show == | + | === read and show === |
I think the names <hask>read</hask> and <hask>show</hask> in the Prelude of Haskell98 aren't a good choice | I think the names <hask>read</hask> and <hask>show</hask> in the Prelude of Haskell98 aren't a good choice | ||
| Line 87: | Line 87: | ||
The choice for the Modula-3 libraries (<hask>Lex</hask> and <hask>Fmt</hask>) seems to be more suitable. -- HenningThielemann | The choice for the Modula-3 libraries (<hask>Lex</hask> and <hask>Fmt</hask>) seems to be more suitable. -- HenningThielemann | ||
| - | == trees == | + | === trees === |
I had a nice discussion the other day with someone about the right name for tree nodes and leaves. The constructors I'm using as a result are <hask>Branch</hask> and <hask>Leaf</hask>. Anyone feel differently? -- BartMassey | I had a nice discussion the other day with someone about the right name for tree nodes and leaves. The constructors I'm using as a result are <hask>Branch</hask> and <hask>Leaf</hask>. Anyone feel differently? -- BartMassey | ||
| + | |||
| + | [[Category:Style]] | ||
| + | |||
| + | === Del === | ||
| + | I think 'del' is more natural pair for 'add'. --Evgeny Tarasov | ||
Current revision
Frequently functions appear in pairs likehOpen
hClose
read
show
Libraries are a lot easier to use if they use a consistent scheme of names for related functions. It is even better if many libraries would share the same scheme. This can be useful both for designing function names and for easy guessing of the counterpart of some function.
Here is a collection of some pairs of identifiers I stumbled on in AmigaOS, MUI, Modula-3, Haskell libraries, and C++ STL. This could be a basis for further discussion.
It would be great if the discussion lead to a more streamlined collection where for instance some duplicates are removed.
| Create | Delete | |
| New | Dispose | |
| Construct | Destruct | |
| Alloc | Free | |
| Obtain | Release | Attempt |
| Lock | UnLock | |
| Procure | Vacate | |
| Forbid | Permit | |
| Disable | Enable | |
| Put | Get | |
| Set | Get | |
| Write | Read | |
| Poke | Peek | |
| Open | Close | |
| Save | Load | |
| Load | UnLoad | |
| Init | Exit | |
| Setup | Cleanup | |
| Show | Hide | |
| Insert | Remove | |
| Add | Rem | |
| Push | Pull | |
| Push | Pop | |
| Start | Stop | Size |
| Begin | End | Length |
| First | Last | Number |
| Head | Tail | |
| Front | Back | |
| Top | Bottom | |
| Fmt | Lex | |
| Input | Output |
Contents |
1 Discussion
1.1 read and show
I think the namesread
show
because the functions can be considered as natural pair but this isn't reflected by their names.
Even moreread
show
Lex
Fmt
1.2 trees
I had a nice discussion the other day with someone about the right name for tree nodes and leaves. The constructors I'm using as a result areBranch
Leaf
1.3 Del
I think 'del' is more natural pair for 'add'. --Evgeny Tarasov
