Ar an séú lá is fiche de mí na Samhain, scríobh Johann 'Myrkraverk' Oskarsson:
[...] Ok, then the question is, what is a better strategy, not to
implement it at all, which gives the error "Object type has no
properties" which can be slightly surprising and misleading if any of the
(get), (put) and (remprop) are implemented; vs. returning nil?
I'd like answers from people who have actually used property lists for
something; if any.
Implement it. Some (similar-ish) APIs are implemented entirely at Lisp level
and will never give these errors, and it can be surprising to move to a C
API and have it behave so differently. You can use process_putprop,
process_remprop, process_plist, process_setplist from process.c.
And on that note, why is that the internal putprop callback is
supposed to return 0 to throw a lisp error, but the remprop callback
is supposed to return -1? Wouldn't it have been better to synchronize
it? (This is from Fput and Fremprop in fns.c). I also just checked,
and afaict, this has not changed in 21.5. Given how few modules are
actually out there (mine may be the only one who does types) do you
want to change it?
It’s an ugly detail, yes. Send a separate patch to correct it.
> > Also, the (get cursor 'kind) returns another type,
which I've not yet
> > wrapped. This is an enumerator documented at
> >
> >
http://clang.llvm.org/doxygen/group__CINDEX.html#gaaccc432245b4cd9f2d4709...
> >
> > and I wonder what some options are to represent this in elisp?
>
> I would most likely use symbols. Whether to use keywords is a matter
> of taste. I probably wouldn't. [...] Creating a
> separate enum type seems like overengineering; if you want to
> introspect the set of enumerators, a defconst at Lisp level seems
> sufficient. If you really want to, you can create that list read-only
> at the C level in your module.
Overengineering or not, it does make it slightly easier to typecheck
for the functions that take these enumerators as arguments; see here:
http://clang.llvm.org/doxygen/group__CINDEX__CURSOR__MANIP.html#func-members
But that doesn't mean I can't use symbols. Maybe I'll do it the XP
way and try both a type wrapper and symbols to see which feels better.
Another consideration is that there’s a limited number of types available,
256 per XEmacs binary, while there is no significant limitation on the
number of symbols available.
--
‘Tramadol is further fed to cattle […] when working them […] (as draft
animals) so that the animals do not get tired quickly. …’
— Angewandte Chemie, Sept 2014, describing the social context of
(synthetic) tramadol having been found in Cameroon tree roots.
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-beta