babashka-sci-dev 2022-05-25

@ambrosebs I'm still working on the SciType stuff . Let's continue the conversation in a new sub-thread here. I'm losing track of the long thread with 100+ messages we created :)

๐Ÿ‘ 1

Renamed to sci.lang.Type now

๐Ÿ‘ 1

I'll wait to test it out when it lands in bb master.

๐Ÿงต

@ambrosebs Now pushed babashka SciType branch. Conceptually it works. Need to clean up some details that should not be important to the end result.

user=> (defrecord Foo [])
user.Foo
user=> (instance? sci.lang.SciType Foo)
true

user=> (defprotocol P (doit [_]))
..
user=> (extend-protocol P sci.lang.SciType (doit [_] :sci-type))
#object[clojure.lang.MultiFn 0x22f50fc5 "clojure.lang.MultiFn@22f50fc5"]
user=> (doit Foo)
:sci-type

@ambrosebs Is there a reason we couldn't just have exposed an interface?

user=> (extend-protocol P sci.lang.IVar (doit [_] :sci-typex))
#object[clojure.lang.MultiFn 0x22f50fc5 "clojure.lang.MultiFn@22f50fc5"]
user=> (doit #'inc)
:sci-typex

nvm I'm getting the platforms confused.

bb doesn't run in cljs ๐Ÿ™‚

yeah, well, SCI does support JS so it would be good if it worked there too

yes. a deftype seems the most straightforward way to do that perhaps

fair enough

Maybe I should move sci.impl.SciVar to sci.lang too then

in the future, probably not now

enough changes for now :)

ah to expose cross-platform extensions for vars?

yes

๐Ÿ‘ 1

but I was also thinking I could map (extend-protocol clojure.lang.Var ...) to sci.impl.SciVar

as clojure vars should never be visibible directly in SCI anyway

and such a "polyfill" isn't possible with custom types

I guess you could do this as a SCI user with:

{:classes {'clojure.lang.Var sci.lang.SciVar}}
to do the override automatically

Anyway, welcome to test out this approach before I merge it

the sci.lang.SciType one I mean

If you need a binary let me know

Do you have a preference naming-wise for sci.lang.Type vs sci.lang.SciType ?

Hmm I couldn't choose ๐Ÿ™‚

Chicken and egg problem. I'd love to have some feedback before I merge :)

๐Ÿ˜„ 1

I'll take a look when I can ๐Ÿ™‚

I'll probably get back to this in the weekend