1. Stepwise Refinement

One feature I've not seen in many languages, but is occasionally useful, it
that of subfunctions that directly support stepwise refinement of routines.
Here's an example from the ABC language:

 HOW TO RETURN index doc:
    PUT {} IN where
    FOR line.no IN keys doc:
       TREAT LINE
    RETURN where
 TREAT LINE:
    FOR word IN split doc[line.no]:
       IF word not.in keys where:
         PUT {} IN where[word]
       INSERT line.no IN where[word]

Any language that thinks 'HOW TO RETURN' is better than 'FUNCTION' deserves
to die a quick death (as ABC did), but that's not the point here. The
support function TREAT LINE shares the local variables with the main
routine; it's *exactly* the same as:

 HOW TO RETURN index doc:
    PUT {} IN where
      FOR line.no IN keys doc:
      FOR word IN split doc[line.no]:
         IF word not.in keys where:
           PUT {} IN where[word]
         INSERT line.no IN where[word]
    RETURN where

Yes, I know the basic premise of Euphoria is to stay small, prevent feature
creep, and so on. On the other hand, there are quite a number of times when
routines have grown so large they are horribly bloated, but splitting them
up requires creating module variables or awkward forward references. For
example:

   procedure parse()
      if is("function") then  parse_function()
      elsif is("procedure") then parse_procedure()
      ...
      end if
   end procedure

The helper procedures here (parse_function, parse_procedure, etc) often need
to refer back to parse, which requires that it be a forward reference. In
fact, if often requires a host of forward references. In addition, since
these sorts of routines are often recursive, which makes the use of local
variables even more useful.

Since Python (the successor of ABC) doesn't include this sort of feature,
it's not clear that the author considered successive refinement a winning
feature. Still, I think it's worth considering adding to Euphoria.

-- David Cuny

new topic     » topic index » view message » categorize

2. Re: Stepwise Refinement

Hai David

There is a good book about this subject (and also a language
called Elan) . You can find it on ftp.cs.kun.nl/pub/elan

Menno

Date sent:              Tue, 19 Sep 2000 00:04:47 -0700
Send reply to:          Euphoria Programming for MS-DOS <EUPHORIA at
LISTSERV.MUOHIO.EDU>
From:                   David Cuny <dcuny at LANSET.COM>
Subject:                Stepwise Refinement
To:                     EUPHORIA at LISTSERV.MUOHIO.EDU

> One feature I've not seen in many languages, but is occasionally useful, it
> that of subfunctions that directly support stepwise refinement of routines.
> Here's an example from the ABC language:
>
>  HOW TO RETURN index doc:
>     PUT {} IN where
>     FOR line.no IN keys doc:
>        TREAT LINE
>     RETURN where
>  TREAT LINE:
>     FOR word IN split doc[line.no]:
>        IF word not.in keys where:
>          PUT {} IN where[word]
>        INSERT line.no IN where[word]
>
> Any language that thinks 'HOW TO RETURN' is better than 'FUNCTION' deserves
> to die a quick death (as ABC did), but that's not the point here. The
> support function TREAT LINE shares the local variables with the main
> routine; it's *exactly* the same as:
>
>  HOW TO RETURN index doc:
>     PUT {} IN where
>       FOR line.no IN keys doc:
>       FOR word IN split doc[line.no]:
>          IF word not.in keys where:
>            PUT {} IN where[word]
>          INSERT line.no IN where[word]
>     RETURN where
>
> Yes, I know the basic premise of Euphoria is to stay small, prevent feature
> creep, and so on. On the other hand, there are quite a number of times when
> routines have grown so large they are horribly bloated, but splitting them
> up requires creating module variables or awkward forward references. For
> example:
>
>    procedure parse()
>       if is("function") then  parse_function()
>       elsif is("procedure") then parse_procedure()
>       ...
>       end if
>    end procedure
>
> The helper procedures here (parse_function, parse_procedure, etc) often need
> to refer back to parse, which requires that it be a forward reference. In
> fact, if often requires a host of forward references. In addition, since
> these sorts of routines are often recursive, which makes the use of local
> variables even more useful.
>
> Since Python (the successor of ABC) doesn't include this sort of feature,
> it's not clear that the author considered successive refinement a winning
> feature. Still, I think it's worth considering adding to Euphoria.
>
> -- David Cuny

new topic     » goto parent     » topic index » view message » categorize

3. Re: Stepwise Refinement

----- Original Message -----
From: "David Cuny" <dcuny at LANSET.COM>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Tuesday, September 19, 2000 6:04 PM
Subject: Stepwise Refinement


> One feature I've not seen in many languages, but is occasionally useful,
it
> that of subfunctions that directly support stepwise refinement of
routines.

Hi David,
"Stepwise Refinement" sounds like just another term for "forward
references". A bit like "top-down" modular development. All very good,
proven ways to develop high quality software. Pity Euphoria hasn't got it.
Even a pseudo forward reference scheme like 'C' function headers would be
appreciated.

I can imagine something like...

  forward doLine(sequence, atom)

  function Indexer()
     where = gets(1)
     result = doLine(where, 34)
  end function

  function doLine(sequence aLine, integer Posn)
    . . .
  end function
----
cheers,
Derek

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu