https://wiki.haskell.org/api.php?action=feedcontributions&user=Evgenyt&feedformat=atomHaskellWiki - User contributions [en]2024-03-28T16:52:58ZUser contributionsMediaWiki 1.35.5https://wiki.haskell.org/index.php?title=Pairs_of_identifiers&diff=39648Pairs of identifiers2011-04-22T18:35:07Z<p>Evgenyt: /* Del */</p>
<hr />
<div>Frequently functions appear in pairs like <hask>hOpen</hask> and <hask>hClose</hask>, <hask>read</hask> and <hask>show</hask> and so on.<br />
Libraries are a lot easier to use if they use a consistent scheme of names for related functions.<br />
It is even better if many libraries would share the same scheme.<br />
This can be useful both for designing function names and<br />
for easy guessing of the counterpart of some function.<br />
<br />
Here is a collection of some pairs of identifiers I stumbled on<br />
in AmigaOS, MUI, Modula-3, Haskell libraries, and C++ STL.<br />
This could be a basis for further discussion.<br />
<br />
It would be great if the discussion lead to a more streamlined collection<br />
where for instance some duplicates are removed.<br />
<br />
{|<br />
| Create || Delete<br />
|-<br />
| New || Dispose<br />
|-<br />
| Construct || Destruct<br />
|-<br />
| Alloc || Free<br />
|-<br />
| Obtain || Release || Attempt<br />
|-<br />
| Lock || UnLock<br />
|-<br />
| Procure || Vacate<br />
|-<br />
| Forbid || Permit<br />
|-<br />
| Disable || Enable<br />
|-<br />
| Put || Get<br />
|-<br />
| Set || Get<br />
|-<br />
| Write || Read<br />
|-<br />
| Poke || Peek<br />
|-<br />
| Open || Close<br />
|-<br />
| Save || Load<br />
|-<br />
| Load || UnLoad<br />
|-<br />
| Init || Exit<br />
|-<br />
| Setup || Cleanup<br />
|-<br />
| Show || Hide<br />
|-<br />
| Insert || Remove<br />
|-<br />
| Add || Rem<br />
|-<br />
| Push || Pull<br />
|-<br />
| Push || Pop<br />
|-<br />
| Start || Stop || Size<br />
|-<br />
| Begin || End || Length<br />
|-<br />
| First || Last || Number<br />
|-<br />
| Head || Tail<br />
|-<br />
| Front || Back<br />
|-<br />
| Top || Bottom<br />
|-<br />
| Fmt || Lex<br />
|-<br />
| Input || Output<br />
|-<br />
|}<br />
<br />
== Discussion ==<br />
<br />
=== read and show ===<br />
<br />
I think the names <hask>read</hask> and <hask>show</hask> in the Prelude of Haskell98 aren't a good choice<br />
because the functions can be considered as natural pair<br />
but this isn't reflected by their names.<br />
Even more <hask>read</hask> and <hask>show</hask> sound like some I/O operations which they are not.<br />
The choice for the Modula-3 libraries (<hask>Lex</hask> and <hask>Fmt</hask>) seems to be more suitable. -- HenningThielemann<br />
<br />
=== trees ===<br />
<br />
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<br />
<br />
[[Category:Style]]<br />
<br />
=== Del ===<br />
I think 'del' is more natural pair for 'add'. --Evgeny Tarasov</div>Evgenythttps://wiki.haskell.org/index.php?title=Pairs_of_identifiers&diff=39647Pairs of identifiers2011-04-22T18:34:38Z<p>Evgenyt: /* trees */</p>
<hr />
<div>Frequently functions appear in pairs like <hask>hOpen</hask> and <hask>hClose</hask>, <hask>read</hask> and <hask>show</hask> and so on.<br />
Libraries are a lot easier to use if they use a consistent scheme of names for related functions.<br />
It is even better if many libraries would share the same scheme.<br />
This can be useful both for designing function names and<br />
for easy guessing of the counterpart of some function.<br />
<br />
Here is a collection of some pairs of identifiers I stumbled on<br />
in AmigaOS, MUI, Modula-3, Haskell libraries, and C++ STL.<br />
This could be a basis for further discussion.<br />
<br />
It would be great if the discussion lead to a more streamlined collection<br />
where for instance some duplicates are removed.<br />
<br />
{|<br />
| Create || Delete<br />
|-<br />
| New || Dispose<br />
|-<br />
| Construct || Destruct<br />
|-<br />
| Alloc || Free<br />
|-<br />
| Obtain || Release || Attempt<br />
|-<br />
| Lock || UnLock<br />
|-<br />
| Procure || Vacate<br />
|-<br />
| Forbid || Permit<br />
|-<br />
| Disable || Enable<br />
|-<br />
| Put || Get<br />
|-<br />
| Set || Get<br />
|-<br />
| Write || Read<br />
|-<br />
| Poke || Peek<br />
|-<br />
| Open || Close<br />
|-<br />
| Save || Load<br />
|-<br />
| Load || UnLoad<br />
|-<br />
| Init || Exit<br />
|-<br />
| Setup || Cleanup<br />
|-<br />
| Show || Hide<br />
|-<br />
| Insert || Remove<br />
|-<br />
| Add || Rem<br />
|-<br />
| Push || Pull<br />
|-<br />
| Push || Pop<br />
|-<br />
| Start || Stop || Size<br />
|-<br />
| Begin || End || Length<br />
|-<br />
| First || Last || Number<br />
|-<br />
| Head || Tail<br />
|-<br />
| Front || Back<br />
|-<br />
| Top || Bottom<br />
|-<br />
| Fmt || Lex<br />
|-<br />
| Input || Output<br />
|-<br />
|}<br />
<br />
== Discussion ==<br />
<br />
=== read and show ===<br />
<br />
I think the names <hask>read</hask> and <hask>show</hask> in the Prelude of Haskell98 aren't a good choice<br />
because the functions can be considered as natural pair<br />
but this isn't reflected by their names.<br />
Even more <hask>read</hask> and <hask>show</hask> sound like some I/O operations which they are not.<br />
The choice for the Modula-3 libraries (<hask>Lex</hask> and <hask>Fmt</hask>) seems to be more suitable. -- HenningThielemann<br />
<br />
=== trees ===<br />
<br />
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<br />
<br />
[[Category:Style]]<br />
<br />
=== Del ===<br />
I think 'del' is more natural pair for 'add'.</div>Evgenyt