Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.* 1 > Newsgroup comp.lang.ada

Reply
 
Thread Tools Display Modes
  #76 (permalink)  
Old 02-17-2012, 09:12 PM
Yannick Duchêne (Hibou57)
Guest
 
Posts: n/a
Default Re: Convention for naming of anything

Le Fri, 17 Feb 2012 22:53:49 +0100, Manuel Collado
<m.collado@domain.invalid> a écrit:
> At first glance, it seems more "natural":
>
> X -> X
> X' -> X1
> X'' -> X2
> etc.


Good point indeed. While X2 may more clearly express this is a value of X
derived from X, I agree this seems odd to have X' = X2, X'' = X3 andso on.

Will balance yours and mine. Thanks for the comment Manuel, will keep it
in mind :-)

--
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #77 (permalink)  
Old 02-17-2012, 10:52 PM
Adam Beneschan
Guest
 
Posts: n/a
Default Re: Convention for naming of anything

On Feb 16, 9:44*am, Yannick Duchne (Hibou57)
<yannick_duch...@yahoo.fr> wrote:
> Le Thu, 09 Feb 2012 22:10:12 +0100, Yannick Duchne (Hibou57)
> <yannick_duch...@yahoo.fr> a crit:
>
> > Hi people out there,

>
> With functional representation in mind, when an object X' is a value
> derived from an object X in a recursive algorithm, which way do you name
> both X and X', as the Prime symbol is not allowed in Ada names?
>
> * * X1 and X2 ?
> * * X_1 and X_2 ?
> * * X and X2 ?
> * * X and X_2 ?
> * * X and X_Prime ?
> * * X and New_X ?
> * * X and Derived_X ?


It looks like Unicode characters 02B9 and 02CA are both allowed in
identifiers. Maybe you could one of those as your prime symbol?

-- Adam
Reply With Quote
  #78 (permalink)  
Old 02-17-2012, 11:24 PM
Yannick Duchêne (Hibou57)
Guest
 
Posts: n/a
Default Re: Convention for naming of anything

Le Sat, 18 Feb 2012 00:52:41 +0100, Adam Beneschan <adam@irvine.com> a
écrit:
> It looks like Unicode characters 02B9 and 02CA are both allowed in
> identifiers. Maybe you could one of those as your prime symbol?


I've just checked, U+02CA is an accent, U+02B9 is a prime (as a modifier
letter, not a standalone glyph). At least GNAT reject it. Will check the
RM tomorrow (if ever GNAT is wrong).

Thanks for the point anyway, Adam.

--
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University
Reply With Quote
  #79 (permalink)  
Old 02-17-2012, 11:50 PM
Yannick Duchêne (Hibou57)
Guest
 
Posts: n/a
Default Re: Convention for naming of anything

Le Sat, 18 Feb 2012 01:24:40 +0100, Yannick Duchêne (Hibou57)
<yannick_duchene@yahoo.fr> a écrit:
> I've just checked, U+02CA is an accent, U+02B9 is a prime (as a modifier
> letter, not a standalone glyph). At least GNAT reject it. Will check the
> RM tomorrow (if ever GNAT is wrong).


No, GNAT is right, and I was wrong. Xʹ is OK and just requires to pass
“-gnatiw -gnatW8” options to GNAT.

“-gnatiw”: allows character code out of ASCII in names.
“-gnatW8”: tell GNAT the source file is UTF-8 encoded.

“-gnatW8” works alone, but I feel its safer to use “-gnatiw -gnatW8”, to
be more explicite.

Xʹ looks very similar to X' (attribute, type qualification), although the
compiler will probably help to catch it. This depends on font too.

Xˊ is far less similar to X', but does not really stands for prime,it
precisely is “Modifier Letter Acute Accent”. But don't bother, as the
effective meaning is clear.


--
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University
Reply With Quote
  #80 (permalink)  
Old 02-18-2012, 10:32 AM
Georg Bauhaus
Guest
 
Posts: n/a
Default Re: Convention for naming of anything

On 16.02.12 18:44, Yannick Duchêne (Hibou57) wrote:
> Le Thu, 09 Feb 2012 22:10:12 +0100, Yannick Duchêne (Hibou57) <yannick_duchene@yahoo.fr> a écrit:
>
>> Hi people out there,

>
> With functional representation in mind, when an object X' is a value derived from an object X in a recursive algorithm, which way do you name both X and X', as the Prime symbol is not allowed in Ada names?
>
> * X1 and X2 ?
> * X_1 and X_2 ?
> * X and X2 ?
> * X and X_2 ?
> * X and X_Prime ?
> * X and New_X ?
> * X and Derived_X ?


XX for x', XS for lists.

If both a letter with prime and a letter with plural s occur
in the same function, I'd choose a different prefix letter
for either.

Reply With Quote
  #81 (permalink)  
Old 02-18-2012, 12:02 PM
Yannick Duchêne (Hibou57)
Guest
 
Posts: n/a
Default Re: Convention for naming of anything

Le Sat, 18 Feb 2012 12:32:40 +0100, Georg Bauhaus
<rm.dash-bauhaus@futureapps.de> a écrit:

> On 16.02.12 18:44, Yannick Duchêne (Hibou57) wrote:
>> Le Thu, 09 Feb 2012 22:10:12 +0100, Yannick Duchêne (Hibou57)
>> <yannick_duchene@yahoo.fr> a écrit:
>>
>>> Hi people out there,

>>
>> With functional representation in mind, when an object X' is a value
>> derived from an object X in a recursive algorithm, which way do you
>> name both X and X', as the Prime symbol is not allowed in Ada names?
>>
>> * X1 and X2 ?
>> * X_1 and X_2 ?
>> * X and X2 ?
>> * X and X_2 ?
>> * X and X_Prime ?
>> * X and New_X ?
>> * X and Derived_X ?

>
> XX for x', XS for lists.


XS seems Okay for lists, while it may conflict with package names if you
use plural for these too.

XX seems Okay for X', except when X is a longer name.

> If both a letter with prime and a letter with plural s occur
> in the same function, I'd choose a different prefix letter
> for either.


Right, but then, there is typically something like Head and Tail in the
place, which does not use the plural. So this does not may not necessarily
be an issue.


--
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University
Reply With Quote
  #82 (permalink)  
Old 02-18-2012, 09:53 PM
BrianG
Guest
 
Posts: n/a
Default Re: Convention for naming of anything

On 02/17/2012 07:50 PM, Yannick Duchêne (Hibou57) wrote:
> Le Sat, 18 Feb 2012 01:24:40 +0100, Yannick Duchêne (Hibou57)
> <yannick_duchene@yahoo.fr> a écrit:
>> I've just checked, U+02CA is an accent, U+02B9 is a prime (as a
>> modifier letter, not a standalone glyph). At least GNAT reject it.
>> Will check the RM tomorrow (if ever GNAT is wrong).

>
> No, GNAT is right, and I was wrong. Xʹ is OK and just requires to pass
> “-gnatiw -gnatW8” options to GNAT.
>
> “-gnatiw”: allows character code out of ASCII in names.
> “-gnatW8”: tell GNAT the source file is UTF-8 encoded.
>
> “-gnatW8” works alone, but I feel its safer to use “-gnatiw -gnatW8”, to
> be more explicite.
>
> Xʹ looks very similar to X' (attribute, type qualification), although
> the compiler will probably help to catch it. This depends on font too.
>
> Xˊ is far less similar to X', but does not really stands for prime, it
> precisely is “Modifier Letter Acute Accent”. But don't bother, as the
> effective meaning is clear.
>
>

Just don't use a name like XʹFirst :-) What about Xʹs for plural?

--
---
BrianG
000
@[Google's email domain]
..com
Reply With Quote
  #83 (permalink)  
Old 02-19-2012, 10:16 AM
Simon Wright
Guest
 
Posts: n/a
Default Re: Convention for naming of anything

BrianG <me@null.email> writes:

> What about Xʹs for plural?


No, no!

http://en.wikipedia.org/wiki/Apostro...strophes.22.29
Reply With Quote
  #84 (permalink)  
Old 02-19-2012, 05:07 PM
Phil Clayton
Guest
 
Posts: n/a
Default Re: Convention for naming of anything

On Feb 16, 5:44*pm, Yannick Duchêne (Hibou57)
<yannick_duch...@yahoo.fr> wrote:
> With functional representation in mind, when an object X' is a value
> derived from an object X in a recursive algorithm, which way do you name
> both X and X', as the Prime symbol is not allowed in Ada names?


To refer to before and after values of a variable in e.g. a
postcondition, the convention of suffixing a subscript-zero to denote
the before value is fairly common in formal methods texts, e.g. the
classic "Programming from Specifications":
http://www.cs.ox.ac.uk/publications/books/PfS/
So, for example, the postcondition
X = X₀ + 1
says that the value of X is increased by 1. Perhaps an ASCII
equivalent would be
X = X_0 + 1

I've come across exactly this conflict with primes in the past. The
Ada verification tool, DAZ - built on ProofPower, see
http://www.lemma-one.com/ProofPower/index/
- would have ideally used a prime to denote an after value because
that is the convention of the Z notation, the language used to express
pre- and postconditions of Ada statements. Instead it uses a
subscript-zero for the before value, like in Programming from
Specifications, on which it was based.

Phil
Reply With Quote
  #85 (permalink)  
Old 02-19-2012, 08:53 PM
Yannick Duchêne (Hibou57)
Guest
 
Posts: n/a
Default Re: Convention for naming of anything

Le Sun, 19 Feb 2012 19:07:15 +0100, Phil Clayton
<phil.clayton@lineone.net> a écrit:
> To refer to before and after values of a variable in e.g. a
> postcondition, the convention of suffixing a subscript-zero to denote
> the before value is fairly common in formal methods texts, e.g. the
> classic "Programming from Specifications":
> http://www.cs.ox.ac.uk/publications/books/PfS/
> So, for example, the postcondition
> X = X₀ + 1
> says that the value of X is increased by 1. Perhaps an ASCII
> equivalent would be
> X = X_0 + 1


Prior side note: I’ve checked GNAT reject it, the ₀, with a message
“invalid wide character in identifier”, and this time, that's not due to
missing compiler options. Will really need to check the RM for these
characters, so my comments may not not relevant.

X₀ or X_0 Could be an option if everything was formal in a given
application. But when a specification is expected to be exposed with a
classic look, this would imply giving subprograms argument names like X₀
or X_0, as the “value before” is often from the subprogram parameters, and
this wouldn't look as expected.

May be OK or not, depending on the overall style of an application.

But you gave me the idea X₁, X₂, X₃ could be alternatives to Xʹ or Xˊ,
more distinctive, except it may make readers think they are list indexes
or polynomial indexes…

Hint: ₀ is U+2080, ₁ is U+2081, and so on, up to ₉.. Use of a character
palette is probably recommended to help.


> http://www.cs.ox.ac.uk/publications/books/PfS/
> […]
> I've come across exactly this conflict with primes in the past. The
> Ada verification tool, DAZ - built on ProofPower, see
> http://www.lemma-one.com/ProofPower/index/


Cool links, especially the former :-) Thanks

--
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University
Reply With Quote
  #86 (permalink)  
Old 02-19-2012, 11:21 PM
Phil Clayton
Guest
 
Posts: n/a
Default Re: Convention for naming of anything

On Feb 19, 9:53*pm, Yannick Duchêne (Hibou57)
<yannick_duch...@yahoo.fr> wrote:
> Le Sun, 19 Feb 2012 19:07:15 +0100, Phil Clayton
> <phil.clay...@lineone.net> a écrit:
>
> > To refer to before and after values of a variable in e.g. a
> > postcondition, the convention of suffixing a subscript-zero to denote
> > the before value is fairly common in formal methods texts, e.g. the
> > classic "Programming from Specifications":
> >http://www.cs.ox.ac.uk/publications/books/PfS/
> > So, for example, the postcondition
> > * X = X₀ + 1
> > says that the value of X is increased by 1. *Perhaps an ASCII
> > equivalent would be
> > * X = X_0 + 1

>
> Prior side note: I’ve checked GNAT reject it, the ₀, witha message
> “invalid wide character in identifier”, and this time, that's not due to
> missing compiler options. Will really need to check the RM for these
> characters, so my comments may not not relevant.
>
> X₀ or X_0 Could be an option if everything was formal in a given
> application. But when a specification is expected to be exposed with a
> classic look, this would imply giving subprograms argument names like X₀
> or X_0, as the “value before” is often from the subprogram parameters, and
> this wouldn't look as expected.
>
> May be OK or not, depending on the overall style of an application.
>
> But you gave me the idea X₁, X₂, X₃ could be alternatives to Xʹ or Xˊ,
> more distinctive, except it may make readers think they are list indexes
> or polynomial indexes…
>
> Hint: ₀ is U+2080, ₁ is U+2081, and so on, up to ₉. Use of a character
> palette is probably recommended to help.


For before and after values, perhaps X_Old and X is worth considering
- then a postcondition e.g.
X = X_Old + 1
would look more like it would for a program with a destructive update
of X:
X = X'Old + 1


> >http://www.cs.ox.ac.uk/publications/books/PfS/
> > […]
> > I've come across exactly this conflict with primes in the past. *The
> > Ada verification tool, DAZ - built on ProofPower, see
> >http://www.lemma-one.com/ProofPower/index/

>
> Cool links, especially the former :-) Thanks


I don't know of anyone who actually derives programs for real as
described in PfS, but understanding the formal program development
methods helps one justify or explain a program - not necessarily a
formal argument but perhaps just better comments or more useful pre/
postconditions for run-time checking.

The DAZ tool checks PfS-style refinement arguments. For example

𝚫 X [ true, X = X₀ + 1 ]

X := X + 1;

would produce a verification condition, which, if provable means that
the code is a valid implementation of the specification statement. As
far as I know, DAZ was never used to develop programs (as described in
PfS) but to check already written programs against a specification by
'recovering' a refinement that gave provable verification conditions.
Then, verification conditions are shown to be provable by proving them
- the subject of theorem proving is yet another (fascinating) world.
Use of such tools tends to be limited to very critical systems. In
fact, the analysis is very similar to compliance analysis with the
SPARK examiner, though the presentation is very different.

Phil
Reply With Quote
  #87 (permalink)  
Old 03-05-2012, 11:36 PM
Randy Brukardt
Guest
 
Posts: n/a
Default Re: Convention for naming of anything

"Simon Wright" <simon@pushface.org> wrote in message
news:m2r4xr13b2.fsf@pushface.org...
> BrianG <me@null.email> writes:
>
>> What about X's for plural?

>
> No, no!
>
> http://en.wikipedia.org/wiki/Apostro...strophes.22.29


Cool. I always thought that the 's plurals littering the comments in
Janus/Ada (put there by others; I'm forever removing them) were illiteracy,
but now I know that they are just archaic. Big difference. :-)

Randy.


Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 01:52 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.