[plt-scheme] Implicit begins (and programming style)

From: Daniel Silva (daniel.silva at gmail.com)
Date: Tue Nov 23 14:16:57 EST 2004

I'd say keep doing without the explicit begins.  I think it's pretty
much understood that if you see a sequence of commands followed by an
expression, then a begin is implied.

It would be nice too if begin started a definition context, so we could say

(when something?
  (define x y)
  (blah x x))

instead of

(when something?
  (let ([x y])
    (blah x x)))

or the cheater's option of

(when something?
  (let ()
    (define x y)
    (blah x x)))

, though maybe

(when something?
  (with (x y)
    (blah x x)))

is sufficient?  I still think the first one is easier on the eyes...


On Tue, 23 Nov 2004 16:54:03 +0100, Thomas-Xavier MARTIN
<txm+plt-scheme at m4x.org> wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> Disclaimer : I am aware that scheme code should be as functional as possible,
> and that begins are only necessary/useful/legitimate when side-effects are
> needed. But some programs need side-effects... So :
> Which forms include an implicit begin ?
> So far, I have noted :
> - lambda, define (for procedures, not for variables)
> - let, letrec, let*
> - cond, when, unless (not if !)
> Any others ? Any definitive list somewhere ?
> Googling has given me this, which has a few more (case, do, fluid-let,
> named-lambda) :
> http://www.cs.colorado.edu/~main/manuals/scheme/scheme_39.html
> but it does not pretend to be exhaustive...
> Style-wise, should one write code with explicit begins even where they are not
> needed, for readability (apart from specific cases with heavy indentation, I
> do not see using explicit begins as more readable ; am I wrong ?) or on the
> contrary, avoid writing begins anyplace it is possible for conciseness ?
> Since I mentionned Scheme programming style (this should probably be a
> separate post, sorry !), I have googled extensively for scheme style guides,
> and while I found two that are useful, they do not go as far as I would
> like...
> http://community.schemewiki.org/?scheme-style
> http://web.archive.org/web/20020809131500/www.cs.dartmouth.edu/~cs18/F2002/handouts/scheme-tips.html
> Any pointers to discussions or pages on Scheme programming style would be
> appreciated. Currently, I read as much code as I can, and try to imitate the
> style of what I find readable while avoiding the style of  what I can't
> parse. It's a good and tried method, but style guides allow for more
> efficient leveraging of other people's experience.
> --
> Sincerely,
> Thomas-Xavier MARTIN
> txm+plt-scheme at m4x.org

Posted on the users mailing list.