GithubHelp home page GithubHelp logo

Comments (10)

louis77 avatar louis77 commented on August 12, 2024 1

@Hexstream Well, thank you very much for spending 30 seconds to reformat my example code. Greatly appreciated.

from closer-mop.

louis77 avatar louis77 commented on August 12, 2024 1

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.

pcostanza avatar pcostanza commented on August 12, 2024 1

@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.

Hexstream avatar Hexstream commented on August 12, 2024

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.

louis77 avatar louis77 commented on August 12, 2024

I haven't looked into this, but

@Hexstream
How is that related to the issue?

from closer-mop.

Hexstream avatar Hexstream commented on August 12, 2024

Less unrelated warnings makes it easier to investigate the issue, for one thing.

from closer-mop.

pcostanza avatar pcostanza commented on August 12, 2024

Try this:

(mapcar (lambda (s) (slot-boundp-using-class *class* *inst* s)) (mapcar 'slot-definition-name (class-slots *class*)))

from closer-mop.

pcostanza avatar pcostanza commented on August 12, 2024

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.

Hexstream avatar Hexstream commented on August 12, 2024

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.

Hexstream avatar Hexstream commented on August 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.