comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Pondering what rationale behind record type
Date: Wed, 11 May 2011 09:32:12 +0200
Date: 2011-05-11T09:32:13+02:00	[thread overview]
Message-ID: <ci3lz2rpjwjf$.15yccznaasoyg.dlg@40tude.net> (raw)
In-Reply-To: 9543fcbd-9035-45d3-8a5b-45592f927685@w10g2000yqa.googlegroups.com

On Tue, 10 May 2011 19:28:16 -0700 (PDT), Shark8 wrote:

> On May 10, 7:50�am, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> wrote:
>>
>> What is the reason to name statements?
> 
> Simple: to aid in readability.
> I have a few rather deeply nested items where I'm tokenizing
> PostScript
> (due the rules of the language) and it is handy to have things like
> -- Case C, When C '<' =>
> Read_Character( C, Input );
> HANDLE_LT: -- less than
> if C = '<' then
>  Return Dictionary_Type;
> elsif C = '~' then
>  Return String_Type;
> else
>  Unread_Character( C, Input );
>  Return -- I forgot what the last case, just '<', was...
> end if HANDLE_LT;

The above should have been a "case", or better matching the input against a
token table with semantic callbacks doing things.

> There's even a few in blocks where I handle things like
> names ['identifiers'] vs. numbers; the PLRM defines a name
> as a string of "regular characters which cannot be interpreted
> as a string." This means that 23E4 is a number while 24F4 is
> a name as are $4, 2i3, @, 2^4 and so forth.

That is semantic analysis to me. No need to burden parser with that. You
parse 23E4 as a token and later interpret it as an identifier or number.

> It REALLY does help in sorting where you are in the decoding.

I don't think that large "if"s is a good style. No names may help that.
BTW, in your case "then", "else", "elsif" must carry the name of the "if"
they belong.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2011-05-11  7:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-09 17:47 Pondering what rationale behind record type Anh Vo
2011-05-09 18:59 ` Adam Beneschan
2011-05-09 19:51   ` Niklas Holsti
2011-05-09 20:02     ` Dmitry A. Kazakov
2011-05-09 20:12       ` Anh Vo
2011-05-09 22:03         ` Georg Bauhaus
2011-05-10  7:45           ` Dmitry A. Kazakov
2011-05-10 10:12             ` Georg Bauhaus
2011-05-10 12:08               ` Dmitry A. Kazakov
2011-05-10 12:18                 ` Georg Bauhaus
2011-05-10 12:50                   ` Dmitry A. Kazakov
2011-05-10 14:20                     ` Martin
2011-05-11  7:32                       ` Dmitry A. Kazakov
2011-05-11  2:28                     ` Shark8
2011-05-11  7:32                       ` Dmitry A. Kazakov [this message]
2011-05-18 22:55                         ` Shark8
2011-05-19  8:12                           ` Dmitry A. Kazakov
2011-05-09 20:49   ` Randy Brukardt
2011-05-19  9:50 ` J-P. Rosen
2011-05-20  6:10 ` anon
replies disabled

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