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

Mutation not happening for a deftype #66

Closed
pfeodrippe opened this issue May 14, 2022 · 2 comments
Closed

Mutation not happening for a deftype #66

pfeodrippe opened this issue May 14, 2022 · 2 comments

Comments

@pfeodrippe
Copy link
Contributor

pfeodrippe commented May 14, 2022

I'm running the code below and I would expect {:v 40} as the output.

(ns quickstart.helloworld)

(defprotocol ITestProtocol
  (act [_ _]))

(deftype Test [^:mutable x-a]
  ITestProtocol
  (act [this o] (set! x-a o))

  Object
  (toString [this]
    (str x-a)))

(def t (Test. 10))
(act t 40)

(defn main []
  (print {:v t}))

But I'm having

{:v 10}

When I move (act t 40) to main, I have the following error

Unhandled exception:
Exception: No extension of protocol ITestProtocol found for type int.
#0      ITestProtocol$iprot.extensions (file:///Users/paulo.feodrippe/dev/dartapp/lib/cljd-out/quickstart/helloworld.dart:47:1)
#1      main (file:///Users/paulo.feodrippe/dev/dartapp/lib/cljd-out/quickstart/helloworld.dart:97:37)
#2      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#3      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
@pfeodrippe pfeodrippe changed the title Mutation not happening in deftype Mutation not happening for deftype May 14, 2022
@pfeodrippe pfeodrippe changed the title Mutation not happening for deftype Mutation not happening for a deftype May 14, 2022
@cgrand
Copy link
Contributor

cgrand commented May 14, 2022

Top level mutation is not supported.

Now the (act t 40) in the main should work. I think the problem comes from the (act _ _) declaration. Please try with distinct parameter names.

@pfeodrippe
Copy link
Contributor Author

pfeodrippe commented May 14, 2022

Nice thanks!!

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

No branches or pull requests

2 participants