From: "Issac Trotts" <ijtrotts@ucdavis.edu>
Subject: Re: C++ declaration style programming?
Date: Tue, 20 Jan 2004 20:57:35 -0800 [thread overview]
Message-ID: <20040121045735.GB3375@manzanita> (raw)
In-Reply-To: <16397.43262.881852.180514@localhost.localdomain>
On Tue, Jan 20, 2004 at 11:17:34PM +0100, Han-Wen Nienhuys wrote:
>
> Hi there,
>
> I just realized that one of the things that I dislike about Scheme is
> that my habit of naming intermediate results (which I inherited from
> C++) leads to deep nesting.
>
> Usually in C++, I do
>
> int var1 = something ();
> int var2 = something (var1);
> int var3 = something (var1, var2);
> etc.
>
> in Scheme, this translates quite well to (let* ) :
>
> (let*
> ((var1 (something))
> (var2 (something var1))
> (var3 (something var1 var2)))
> .. )
>
> However, it doesn't work so well when I mix commands with
> declarations, eg.
>
>
> int var1 = something ();
> var1 += 2;
> int var2 = something (var1);
> var2 += var1;
> int var3 = something (var1, var2);
> etc.
Well, in this case you could do something more functional:
(define (something . x) 1)
(let*
((var1 (+ 2 (something)))
(var2 (+ (something var1) var1))
(var3 (something var1 var2)))
(display `(,var1 ,var2 ,var3)))
> This can presumably be done by writing a macro begin-let* that expands
> the statement list in a suitably nested let*
>
> However, I was wondering whether there exists a standard library
> syntax mechanism that lets me write code in this fashion.
>
> --
>
> Han-Wen Nienhuys | hanwen@xs4all.nl | http://www.xs4all.nl/~hanwen
>
>
>
> _______________________________________________
> Guile-user mailing list
> Guile-user@gnu.org
> http://mail.gnu.org/mailman/listinfo/guile-user
--
Issac Trotts
http://redwood.ucdavis.edu/~issac
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
next prev parent reply other threads:[~2004-01-21 4:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-20 22:17 C++ declaration style programming? Han-Wen Nienhuys
2004-01-21 3:58 ` Viktor Pavlenko
2004-01-21 12:40 ` Han-Wen Nienhuys
2004-01-21 4:57 ` Issac Trotts [this message]
2004-01-21 5:00 ` Stephen Compall
2004-01-21 12:45 ` Han-Wen Nienhuys
2004-01-21 5:03 ` Lynn Winebarger
2004-01-21 21:46 ` Keith Wright
-- strict thread matches above, loose matches on Subject: below --
2004-01-21 14:22 Viktor Pavlenko
2004-01-21 14:26 ` Han-Wen Nienhuys
2004-01-21 15:41 Viktor Pavlenko
2004-01-21 16:06 ` Paul Jarc
2004-01-22 2:24 ` Thien-Thi Nguyen
2004-01-22 4:28 ` Viktor Pavlenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040121045735.GB3375@manzanita \
--to=ijtrotts@ucdavis.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).