From: Jan Wedekind <jan@wedesoft.de>
To: Panicz Maciej Godek <godek.maciek@gmail.com>
Cc: General Guile related discussions <guile-user@gnu.org>,
"Thompson, David" <dthompson2@worcester.edu>
Subject: Interesting project proposal for generics in Racket
Date: Wed, 5 Mar 2014 18:12:00 +0000 (GMT) [thread overview]
Message-ID: <alpine.DEB.2.02.1403051804520.12218@wedemob.home> (raw)
In-Reply-To: <CAMFYt2Zu+XkL9GG+XsohFHKeNw5r_Av=ZDrVySdJnKK5D+R_Ww@mail.gmail.com>
> Besides, I think that Scheme + OOP has its own flaws. In most OOP
> languages, you have this notation object.property or object->method(),
> which also allows for chain calls, i.e. object->getChild()->method(),
> or -- if you have nested objects -- to use
> object.property.propertys_property.
Somewhat related I have seen an interesting project proposal for generics
in Racket [1]. The generics use predicate functions instead of classes.
E.g.:
(defmethod add ((x number?) (y number?))
(+ (x y))
where 'number?' is a function returning '#t' for numbers.
The type hierarchy (specialisation) is declared using 'defsubtype'. E.g.:
(defsubtype zero? integer?)
This facilitates defining factorial like this:
(defgeneric fact (n))
(defmethod fact ((n integer?)) (* n (fact (- n 1))))
(defmethod fact ((n zero?)) 1)
Regards
Jan
[1] https://fenix.tecnico.ulisboa.pt/downloadFile/3779579671692/project.pdf
next prev parent reply other threads:[~2014-03-05 18:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-04 12:57 Article about GNU Guile and GOOPS Jan Wedekind
2014-03-04 14:03 ` Thompson, David
2014-03-04 15:16 ` Panicz Maciej Godek
2014-03-04 18:00 ` Jan Wedekind
2014-03-04 21:17 ` Yawar Amin
2014-03-05 18:12 ` Jan Wedekind [this message]
2014-03-08 9:40 ` Interesting project proposal for generics in Racket Panicz Maciej Godek
2014-03-04 17:41 ` Article about GNU Guile and GOOPS Jan Wedekind
2014-03-05 11:28 ` Nala Ginrut
2014-03-04 14:26 ` Neil Jerram
2014-03-05 15:23 ` Andrew Gwozdziewycz
2014-03-05 17:52 ` Jan Wedekind
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=alpine.DEB.2.02.1403051804520.12218@wedemob.home \
--to=jan@wedesoft.de \
--cc=dthompson2@worcester.edu \
--cc=godek.maciek@gmail.com \
--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).