unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Eric McDonald <mcdonald@phy.cmich.edu>
To: guile-user@gnu.org
Subject: Re: Interesting Behavior of 'append!' In Local Context
Date: Sun, 18 Oct 2009 09:53:12 -0400	[thread overview]
Message-ID: <4ADB1DC8.4050309@phy.cmich.edu> (raw)
In-Reply-To: <1255830356.5591.51.camel@nocandy.dyndns.org>

Stephen Compall wrote:

>     ;; and "your code"
>     (clcase (+ 21 21)
>       ((42) 'its-42)
>       ((84) 'its-84))

[snip]

>> Fair enough. I certainly wouldn't mind seeing "detect and inform"
>> implemented for this case. As a comparison: if I'm writing C or C++
>> code, and I try to modify a const value, the compiler is generally going
>> to let me know.
> 
> A better comparison would be whether the C compiler prevents you from
> mutating a literal through a pointer whose constness has been cast away,
> in a separate compilation unit.

Well, I think that you generally have one C compiler invocation per
compilation unit, and so you lose track of some information between
compilation units. In the cases that we're talking about, everything is
taking place in the same Scheme interpreter session, and so you
shouldn't have to cope with that kind of loss of information...?

Admittedly, it might be difficult to ascertain constness of the list
containing Adams Constant in the above example. But, I think for more
straightforward cases (the majority, perhaps?), such as original
example, I can't imagine that it would be such a difficult task. Andy's
reply seems to concur.

> MzScheme's making pairs immutable by default is a reflection of the
> style of the larger Scheme community, which generally eschews mutating
> list structure in favor of a more functional style.

Sure, agreed. I know that I'm working with a functional language and so
it shouldn't be surprising that functional style is encouraged. I've
actually had quite a bit of experience with Mathematica [1], and so I'm
no stranger to this style of programming. However, there are times when
sequential and iterative logic are more convenient or maintainable, and
since Scheme does provide facilities for that kind of logic, I think I
would be foolish to ignore them. And, when one does iteration, instead
of recursion, it is often more natural to mutate list structure rather
than compose it.

Thanks for the discussion,
  Eric

[1] IIRC, Mathematica provides Protect[] and Unprotect[] for constness
control, and Unevaluated[] (and other mechanisms I can't presently
recall) for evaluation suppression. The orthogonality of these sets of
mechanisms is probably what led to my confusion about how Scheme's quote
works.




  reply	other threads:[~2009-10-18 13:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-17 22:28 Interesting Behavior of 'append!' In Local Context Eric McDonald
2009-10-17 23:09 ` Stephen Compall
2009-10-18  0:36   ` Eric McDonald
2009-10-18  1:45     ` Stephen Compall
2009-10-18 13:53       ` Eric McDonald [this message]
2009-10-18 10:25     ` Andy Wingo

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=4ADB1DC8.4050309@phy.cmich.edu \
    --to=mcdonald@phy.cmich.edu \
    --cc=guile-user@gnu.org \
    /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).