[plt-scheme] boxes?

From: gregory.woodhouse at sbcglobal.net (gregory.woodhouse at sbcglobal.net)
Date: Tue Jan 23 19:54:00 EST 2007

The genesis of my original question was a combination of a misreading of a manual, and the observation that numbers and pairs just don't behave the same way:

> (define (test1 x)
    (set! x 4))
> (define x 1)
> (test1 x)
> x
> (define (test2 x)
    (set-car! x 4))
> (define x '(1 1))
> (test2 x)
> x
(4 1)

Intuitively, I suppose I want to think of (1 1) as a value, not as pointers to 1 and (). That being said, I realize I've written functions to modify lists many times, but it's just not that common to want to be able to emulate integer pointers (unluss you're building an interface to a C program, which is something I have yet to try.)
Gregory Woodhouse 
"Mathematics is the science of patterns."
--Lynn Arthur Steen, 1988

----- Original Message ----
From: Matthias Felleisen <matthias at ccs.neu.edu>
To: Stephen De Gabrielle <spdegabrielle at gmail.com>
Cc: plt-scheme Mailing List <plt-scheme at list.cs.brown.edu>
Sent: Tuesday, January 23, 2007 3:59:47 PM
Subject: Re: [plt-scheme] boxes?

If your method goes down into the dungeons of C/C++ (which is where  
the gui infrastructure lives), it will encounter methods that want to  
return multiple results. Well, in C you can't do this easily  
(allocate a struct, write in the results, return the pointer, ...) so  
people instead pass in several pointers to which the method can write  
results. At some places, the Scheme code reifies this kind of non- 
sense to the Scheme level because it was easy to do so for now, and  
later never arrived.

-- Matthias

On Jan 23, 2007, at 6:51 PM, Stephen De Gabrielle wrote:

> Hi,
> I'm trying to work out boxes;
> the MzScheme manual calls them 'records that have a single  
> field'  [3.11]
> I think I have a handle on how to use them - at least my attempts with
> the 'get-position' method seem to have worked.
> I'm just not sure what the advantage is?
> Any clues appreciated.
> Cheers,
> Stephen De Gabrielle
> --
> (define start (box 2))
> (define end (box 10))
> (send text-editor get-position start end)
> --
>> (send text-editor get-position start end)
>> start
> #&76
>> end
> #&86
>> (unbox start)
> 76
> -- 
> --
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

  For list-related administrative tasks:

Posted on the users mailing list.