Comments (10)
@Hexstream Well, thank you very much for spending 30 seconds to reformat my example code. Greatly appreciated.
from closer-mop.
Thanks a lot @pcostanza. With your remark I was able to get it working on LispWorks 8. Also, I've submitted a PR to the maintainer of the JZON library.
from closer-mop.
@Hexstream Thanks a lot for pointing this out. You are right in the general case. However, in LispWorks, slot-boundp-using-class and friends actually specialize on the slot name, not the effective slot metaclass. When I created Closer to MOP, I had to decide between making things fully compatible, or alternatively, make them compatible only to the extent that they don't hurt performance. I decided for the latter, and that implies that when you call slot-boundp-using-class and friends in LispWorks directly, you won't get compatible behaviour. However, you can define methods on them specialized on effective slot metaclasses, as specified in AMOP, and you will get the correct semantics. For direct calls, always prefer slot-boundp and friends (without -using-class), and you will be fine.
Again, thanks for pointing this out, I should have explained this better immediately.
from closer-mop.
I haven't looked into this, but
(defclass ping-response () ((message :initarg :message)))
(setf *inst* (make-instance 'ping-response :message "test"))
(setf *class* (class-of *inst*))
(mapcar (lambda (s) (slot-boundp-using-class *class* *inst* s)) (class-slots *class*))
would be better written as
(defclass ping-response ()
((message :initarg :message)))
(let* ((instance (make-instance 'ping-response :message "test"))
(class (class-of instance)))
(mapcar (lambda (slot)
(slot-boundp-using-class class instance slot))
(class-slots class)))
from closer-mop.
I haven't looked into this, but
@Hexstream
How is that related to the issue?
from closer-mop.
Less unrelated warnings makes it easier to investigate the issue, for one thing.
from closer-mop.
Try this:
(mapcar (lambda (s) (slot-boundp-using-class *class* *inst* s)) (mapcar 'slot-definition-name (class-slots *class*)))
from closer-mop.
It's normally also not a good idea to call slot-boundp-using-class directly. It's a generic function to define methods on, so slot-boundp can call an optimized version if possible. By calling slot-boundp-using-class directly, you might miss cases where the optimization doesn't apply. So better do this:
(mapcar (lambda (s) (slot-boundp *inst* s)) (mapcar 'slot-definition-name (class-slots *class*)))
from closer-mop.
I certainly don't consider myself as big of a MOP expert as @pcostanza, but according to my reading of the (de facto) standard, slot-boundp-using-class absolutely SHOULD accept an effective slot definition as third argument, and SHOULD NOT accept a slot name instead.
I think this ought to be fixed in the MOP implementations and/or closer-mop. (And user code.)
I also think calling slot-boundp-using-class
directly is or should be totally legit.
Sometimes it's just convenient, and I don't remember the standard hinting it might not be kosher.
from closer-mop.
Thank you for the quick and comprehensive reply!
The obvious solution here, of course, would be for LispWorks to just fix their MOP implementation. :)
Given their deep technical expertise, I'm rather flabberghasted that they haven't yet bothered to address this trivial issue in nearly 30 years... and I can't even imagine that this kind of change would break much user code, and the fix could be opt-in for a few years.
More generally, I am rather amazed that closer-mop is still needed in 2023.
It should nearly be a no-op by now... (trivial-mop
?)
from closer-mop.
Related Issues (17)
- writing a test code HOT 6
- Darcs repository - dates HOT 3
- Documentation and internal symbol exports HOT 9
- Bad conditionalization for lispworks with-hash-table-locked HOT 8
- Problem with closer-mop::only-standard-methods. HOT 8
- Default make-method-lambda doesn't add implicit blocks around the method body. HOT 5
- closer-mop breaks defclass in LispWorks HOT 4
- Build failure with ECL 21.2.1 HOT 2
- LispWorks 8: c2mop:compute-applicable-methods-using-classes's default method specializes wrong class HOT 4
- `mop-features` should be more prominent, and why not integrate it into `closer-mop` as a separately loadable ASDF system? HOT 3
- compute-effective-method-function does not expand implementation-specific macros HOT 1
- [non-conformance] closer-mop shadows call-next-method in make-method-lambda HOT 2
- irregurality on ABCL HOT 2
- Redefined standard-generic-function. HOT 1
- No applicable method for "compute-applicable-methods-using-classes" for ccl on OSX. HOT 2
- Reader functions for method-combination class HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from closer-mop.