Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use ForeignObject>>#copy to copy objects that have no 'copy' member #105

Open
stefreschke opened this issue Feb 6, 2020 · 3 comments
Assignees

Comments

@stefreschke
Copy link

list := Polyglot eval: 'ruby' string: '[]'.
copy := list copy

This throws an Error (Foreign object does not understand "copy"), because ForeignObject>>#copy calls ForeignObject>>#'_dispatch:arguments:ifFail:' with "copy" as member, which the ruby list does not have.

@fniephaus
Copy link
Member

Thanks for the report! What's the expected behavior? If Ruby lists don't implement copy, a debugger seems reasonable. Or would you want the object to behave like a Smalltalk object (actually performing a shallow copy)?

@stefreschke
Copy link
Author

stefreschke commented Feb 7, 2020

Well, since ForeignObject offers a copy and deepCopy method respectively, it would be optimal to receive adequate (shallow) copies or deep copies of these ForeignObjects.

If there is no way to copy/deepCopy those objects language independently and the methods are only meant as a short cut to invoking "copy" members, the debugger is fine. It then reduces to raising awareness that the programmer himself needs to worry about how to copy these objects (e.g. by finding the correct members).

@fniephaus
Copy link
Member

BTW: Ruby lists can be copied with #dup or #clone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants