guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GOOPS functional setter


From: tomas
Subject: Re: GOOPS functional setter
Date: Sun, 15 Jan 2017 10:31:11 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sat, Jan 14, 2017 at 03:16:10PM -0600, Christopher Allan Webber wrote:
> address@hidden writes:
> 
> > Curiously, Jan (also in this thread) came up with "clone",
> > independently.
> 
> Yes you're right. :)
> 
> Speaking of Jan and I both thinking about clone'ish things [...]

> Here's what it looks like in practice, adapting from the
> (srfi srfi-9 gnu) code:
> 
>   (define fsf-address
>     (make <address>
>       #:street "Franklin Street"
>       #:city "Boston"
>       #:country "USA"))
> 
>   (define rms
>     (make <person>
>       #:age 30
>       #:email "address@hidden"
>       #:address fsf-address))
> 
>   (define new-rms
>     (clone rms
>            ((.age) 60)
>            ((.address .street) "Temple Place")))
> 
>   scheme@(guile-user)> (.age rms)
>   $12 = 30
>   scheme@(guile-user)> (.age new-rms)
>   $13 = 60
>   scheme@(guile-user)> (.street (.address rms))
>   $14 = "Franklin Street"
>   scheme@(guile-user)> (.street (.address new-rms))
>   $15 = "Temple Place"
> 
> ... not bad, eh?

You folks rock, seriously :-)

> Updated copy of goops-functional-setter.scm attached!  What do other
> people think?  Should I try to get this upstream in Guile?

I'd love that kind of interface. Feels pretty natural.

regards
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlh7QV8ACgkQBcgs9XrR2kbd5wCfVghdRDiJG5/AfrQ0kWkkNBzC
aZIAn3SFxYRIe4C5pG5LpEzsG2dunJgf
=i7FL
-----END PGP SIGNATURE-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]