[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Several questions
From: |
Michael Livshin |
Subject: |
Re: Several questions |
Date: |
16 Apr 2001 23:25:20 +0300 |
User-agent: |
Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Crater Lake) |
"Ondrej 'SanTiago' Zajicek" <address@hidden> writes:
> - When i have independent modules, which want use same names for their
> methods (with different types of parameters), is there any clean way to
> do it? If i use define-method and export, then define-method doesn't see
> 2. module's generic function and create new one, which overrides it
> during exporting.
you don't need to export methods. as long as you see the generic
*function*, all its methods work. i.e. `define-method' doesn't define
any new name (well, it can magically define the generic function if
it's not defined yet, but then it doesn't matter which module exports
it).
> - Is there any possibility to do finalisation (hooking some function,
> which will be called after (or before) freeing specified object from
> memory)?
there's no way to call a function on an object *after* it has been
freed, because there's no object anymore to call the function on. ;)
otherwise, you have two options:
* if the objects you are interested in are your own smobs, use the
smob free function.
* otherwise, use guardians, kind of like this:
to create a guardian:
(define *g* (make-guardian))
to register an object for finalization:
(*g* my-object)
to finalize:
(and-let* ((o (*g*)))
<do the finalization stuff on `o'>)
as to when and there to do the finalization, the simplest thing is to
add your finalization procedure to `after-gc-hook'.
> - If thread calls lock-mutex and the mutex is already locked, the
> calling thread blocks until the mutex becomes available. But IMHO
> classic mutex should accept more locking from same thread (mutex M owned
> by thread T shouldn't block T's calls lock-mutex M) - it's much more
> useful. So isn't current behaviour a bug (or correct name for this
> object should be lock and not mutex)?
>
> - Is there any possibility to get thread object (object, returned by
> call-with-new-thread) of actual thread?
I'll let someone who knows about threads answer these.
--
I am not a Church numeral!
I am a free variable!