comp.lang.ada
 help / color / mirror / Atom feed
* Naming convention for constructor functions
@ 2008-03-12 13:43 Maciej Sobczak
  2008-03-12 15:15 ` Lucretia
  0 siblings, 1 reply; 4+ messages in thread
From: Maciej Sobczak @ 2008-03-12 13:43 UTC (permalink / raw)


Hi,

What is the established convention for naming constructor functions?
I'm mostly concerned with constructors for limited types, but that
should not matter here.

One nice convention that I've seen is:

type Person (<>) is limited private;
function Make_Person (someparameters) return Person;

I can also imagine Create_T, Construct_T, etc., but Make_T seems to be
the shortest while still conveying the meaning properly. Is it also
most widely used?

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Naming convention for constructor functions
  2008-03-12 13:43 Naming convention for constructor functions Maciej Sobczak
@ 2008-03-12 15:15 ` Lucretia
  2008-03-22  1:31   ` Gene
  2008-03-22 13:01   ` Georg Bauhaus
  0 siblings, 2 replies; 4+ messages in thread
From: Lucretia @ 2008-03-12 15:15 UTC (permalink / raw)


On Mar 12, 1:43 pm, Maciej Sobczak <see.my.homep...@gmail.com> wrote:

> I can also imagine Create_T, Construct_T, etc., but Make_T seems to be
> the shortest while still conveying the meaning properly. Is it also
> most widely used?

IIRC, the style guide mentions both Make_T and Create_T. I can image
Constructor_T being a pain to type after a while, the first 2 convey
meaning and are short, so I'd pick one of those.

Luke.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Naming convention for constructor functions
  2008-03-12 15:15 ` Lucretia
@ 2008-03-22  1:31   ` Gene
  2008-03-22 13:01   ` Georg Bauhaus
  1 sibling, 0 replies; 4+ messages in thread
From: Gene @ 2008-03-22  1:31 UTC (permalink / raw)


On Mar 12, 11:15 am, Lucretia <lucret...@lycos.co.uk> wrote:
> On Mar 12, 1:43 pm, Maciej Sobczak <see.my.homep...@gmail.com> wrote:
>
> > I can also imagine Create_T, Construct_T, etc., but Make_T seems to be
> > the shortest while still conveying the meaning properly. Is it also
> > most widely used?
>
> IIRC, the style guide mentions both Make_T and Create_T. I can image
> Constructor_T being a pain to type after a while, the first 2 convey
> meaning and are short, so I'd pick one of those.
>
> Luke.

That's interesting.  After teaching many beginning programmers I
finaly figured out that if I tell them to name procedures as verbs and
functions as nouns, they more quickly catch on as to the difference.
Therefore I claim there is a lot to recommend New_T as more
intuitive.  It also agrees with the allocator syntax.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Naming convention for constructor functions
  2008-03-12 15:15 ` Lucretia
  2008-03-22  1:31   ` Gene
@ 2008-03-22 13:01   ` Georg Bauhaus
  1 sibling, 0 replies; 4+ messages in thread
From: Georg Bauhaus @ 2008-03-22 13:01 UTC (permalink / raw)


Lucretia wrote:
> On Mar 12, 1:43 pm, Maciej Sobczak <see.my.homep...@gmail.com> wrote:
> 
>> I can also imagine Create_T, Construct_T, etc., but Make_T seems to be
>> the shortest while still conveying the meaning properly. Is it also
>> most widely used?
> 
> IIRC, the style guide mentions both Make_T and Create_T. I can image
> Constructor_T being a pain to type after a while, the first 2 convey
> meaning and are short, so I'd pick one of those.

As Gene has said, Constructor_T is a noun and therefore likely
to be mistaken for a type or object. A convention used
with Ada->JVM-Code compilers is New_T.

I've also seen nested factory packages P used; in this case
there is just P.Make without the type's name in the constructor
function.

As for "pain to type", I can hardly grasp the measure of stunning
ineffective ... stupidity that programmers seem to show when it
comes to using a computer for editing. There is *no* excuse
whatsoever to ignore editing programs and their capabilities of
"typing on command". Most editing programs are even better at
expanding than the mercilessly "helpful" automatic rewriters
in URL input fields or whatever is used in mobile phones.
This is true in particular of lauguage sensitive editors, such
as Emacs with Ada mode, GPS, ADT for Eclipse,  Gnatbench for
Eclipse, etc. etc..

You cannot become a carpenter if you don't know how to use a saw
for cutting wood.
How can you become a programmer if you don't know how to use
a computer for writing program text?

When someone complains that word XYZ is a pain to type he acts
like an apprentice complaining that it is a pain to drill a hole
using finger nails. [End of Steam]



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-03-22 13:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-12 13:43 Naming convention for constructor functions Maciej Sobczak
2008-03-12 15:15 ` Lucretia
2008-03-22  1:31   ` Gene
2008-03-22 13:01   ` Georg Bauhaus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox