Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

naming conventions for constants

4 views
Skip to first unread message

Bernd Paysan

unread,
Mar 18, 2003, 6:12:18 AM3/18/03
to
Darin Johnson wrote:
> What sort of conventions do other people use for generic constants?
> I've consulted the naming convention from Leo Brodie.

Usually #CR, #LF, #BS, #TAB...

--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://www.jwdt.com/~paysan/

Wil Baden

unread,
Mar 18, 2003, 7:32:47 AM3/18/03
to
In article <iuu65b...@miriam.mikron.de>, Bernd Paysan
<bernd....@gmx.de> wrote:

> Usually #CR, #LF, #BS, #TAB...

Bernd's answer is good. My solution, used in Neil Bawd's
cite, is clarity.

There should be no doubt of the meaning of

dup #eol-char = swap #linefeed-char = or

I read a leading "#" before a singular noun as "the". Before
a plural noun as "number of". `

I have a vague theory of clarity as inverse to the number of
steps to get from text to understanding. "#BS", ..., require
an extra step of knowing the usual symbols for the control
characters, and another slight step to recognizing these
words are constants for characters

--
Wil

Graham Smith

unread,
Mar 18, 2003, 8:43:13 AM3/18/03
to
In message <cu14r61...@nokia.com>, Darin Johnson <da...@usa.net>
writes
>OK, this is bugging me. I'm trying to clean up some old code and
>have the following definitions:
> 8 constant =BS
> 10 constant =LF
> 13 constant =CR
> 127 constant =DEL
>
>The problem is that the "=" prefix just doesn't look right.
>It's the convention used in eForth, which counts for something,
>but it just doesn't look right (especially in code like
>"dup =cr = swap =lf = or").

>
>What sort of conventions do other people use for generic constants?
>I've consulted the naming convention from Leo Brodie.
>
I often use a mnemonic between angled brackets. e.g.
#13 constant <CR>
#127 constant <DEL>

where the # indicates a decimal number.

I then find code phrases like "<CR> = if ..." scattered around. i.e.
these constants are ALWAYS followed by an equals.

In these cases I go back and remove the constants and define words such
as
: CR? #13 = ;
: DEL? #127 = ;

I like words ending with a question mark indicating that the result of a
test is returned.

Graham Smith

Rufus V. Smith

unread,
Mar 18, 2003, 9:51:22 AM3/18/03
to

"Bernd Paysan" <bernd....@gmx.de> wrote in message news:iuu65b...@miriam.mikron.de...

> Darin Johnson wrote:
> > What sort of conventions do other people use for generic constants?
> > I've consulted the naming convention from Leo Brodie.
>
> Usually #CR, #LF, #BS, #TAB...
>
And if you want to distinguish it as characters, you could:

C#CR C#LF C#BS

Elizabeth D. Rather

unread,
Mar 18, 2003, 10:58:13 AM3/18/03
to
Darin Johnson wrote:

> OK, this is bugging me. I'm trying to clean up some old code and
> have the following definitions:
> 8 constant =BS
> 10 constant =LF
> 13 constant =CR
> 127 constant =DEL
>

> ...


> What sort of conventions do other people use for generic constants?
> I've consulted the naming convention from Leo Brodie.

Insofar as BL is the standard for hex 20, IMO the names without
any distinguishing symbol are best. However, CR is reserved for
a "newline" function (e.g. CR LF), whatever that may mean for a
particular output device.

I don't see any particular value in designating the defining word
used to produce something; its function is the important information,
not how it was defined.

Cheers,
Elizabeth


Graham Telfer

unread,
Mar 19, 2003, 2:39:55 AM3/19/03
to
I use an underscore followed by an uppercase letter:

_Constant

Variables start with an uppercase letter and end with a tick:

Variable'

Graham Telfer

jrh

unread,
Mar 20, 2003, 3:46:41 AM3/20/03
to
In article <3E774215...@forth.com>, era...@forth.com says...

I agree. Often I start a program using constants, and later change them
to self fetching variables. Any special designations would have to
be updated to maintain consistancy.

<cr> <esc> might be good for charactors, or ARRAY.SIZE for the size of
a buffer, not because they are constants but because of what they represent.

jrh


0 new messages