From: Daniel Hartwig <mandyke@gmail.com>
To: David Pirotte <david@altosw.be>
Cc: guile-devel@gnu.org
Subject: Re: goops - accessors, methods and generics
Date: Fri, 22 Feb 2013 09:16:54 +0800 [thread overview]
Message-ID: <CAN3veRdBaNZBaGVfUcahCB56bNP7+g5qF32FNMXNcS_yX8rs8A@mail.gmail.com> (raw)
In-Reply-To: <20130221195139.59f41d13@capac>
Hi
It seems you are expecting some CLOS behaviour in a language that can
not support it. The accessors are generic functions, but each of your
modules creates a unique generic function, there is no implicit
namespace sharing in Scheme. Define a base module with an appropriate
superclass or interface definition (generics); Scheme requires it.
On 22 February 2013 06:51, David Pirotte <david@altosw.be> wrote:
> Hello all,
>
> given the following 4 modules, I am facing what I consider an
> inconsistent goops behavior and have one problem which leads to my
> recurrent request of goops default behavior should be to
> [a] always
> create a generic function for accessors and methods that do not [yet]
> have one, *visible in the entire guile space [all modules]*
Note that <generic> is a superclass of <accessor>, so these are
already generic functions. There is no global binding escalation in
Scheme.
Consider these situations followed by introducing any of your example
class definitions:
- module A binds ‘define’ to a non-procedure; or
- modules B and C bind ‘define’ to different procedures.
Your suggestion is appropriate in a language like Common Lisp with
dynamic scoping, and separate namespaces for function and non-function
bindings. Not so appropriate for Scheme.
In your example the two classes share a common interface, but this
interface is never defined anywhere. So if I have code that wants to
work with any widget, which module should be imported to get the
canonical interface definition? Indeed, it will either have to be
created using a common superclass or manually defined generics (as you
later observe). These widget implementations will then have to import
the base module to explicitly share in the interface.
> and [b] the
> default behavior should be '(merge-generics replace warn-override-core
> warn last) [but that at least that one I can set using :duplicate, I know]
The default behaviour is conservative with regards to namespace
separation. If you desire this behaviour it seems best to explicitly
ask for it. With CLOS a different default can be expected to apply
because bindings in the underlying language already work in a similar
way.
> what is more of a problem with the existing goops default, for me, is
> expressed in the mg-4.scm 'case': i can not make it work unless I
> manually create another module, manually making generics and make sure
> it is loaded before ...
In a language like Scheme this can not be avoided. Namespaces must be
managed quite explicitly.
In your example, mg-1 and mg-2 are not sharing any bindings. It is
not appropriate to assume that ‘dialog’ in either is related to the
other. If they implement a common interface, as seems obvious in the
example, then they need to import the generic bindings for that from
a common base module. Such a module should either define a superclass
or you can manually define the generics.
> or rename the accessors, which both solutions
> are really against my expectation and [long] CLOS practice: why should
> I have to manually do things which are inherent to oop [same name for
> slots pertaining to different classes is so common that i can not see
> any large application not having to do so, for semantic reasons].
GOOPS can not do everything the same as CLOS due to fundamental
differences between the underlying languages.
If the interface is the same, you have a candidate for superclass.
Either way, any code that hopes to use the (generic) interface needs
to import the bindings from somewhere, and that will be a module
containing either a superclass or a set of manually defined generics.
Regards
next prev parent reply other threads:[~2013-02-22 1:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-21 22:51 goops - accessors, methods and generics David Pirotte
2013-02-22 1:16 ` Daniel Hartwig [this message]
2013-02-22 23:11 ` David Pirotte
2013-02-23 0:37 ` Daniel Hartwig
2013-03-05 23:30 ` David Pirotte
2013-03-06 0:28 ` Mark H Weaver
2013-03-06 14:15 ` Ludovic Courtès
2013-02-23 11:20 ` Stefan Israelsson Tampe
2013-02-23 11:44 ` Stefan Israelsson Tampe
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=CAN3veRdBaNZBaGVfUcahCB56bNP7+g5qF32FNMXNcS_yX8rs8A@mail.gmail.com \
--to=mandyke@gmail.com \
--cc=david@altosw.be \
--cc=guile-devel@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).