Fork me on GitHub
#babashka-sci-dev
<
2022-05-25
>
borkdude10:05:10

@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
borkdude13:05:01

๐Ÿงต

borkdude19:05:10

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

borkdude19:05:52

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

borkdude19:05:50

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

borkdude19:05:44

@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 "[email protected]"]
user=> (doit #'inc)
:sci-typex

ambrosebs19:05:13

hmm good question

ambrosebs19:05:31

what about CLJS?

ambrosebs19:05:13

nvm I'm getting the platforms confused.

ambrosebs19:05:21

bb doesn't run in cljs ๐Ÿ™‚

borkdude19:05:36

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

ambrosebs19:05:25

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

borkdude19:05:35

fair enough

borkdude19:05:49

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

borkdude19:05:01

in the future, probably not now

borkdude19:05:11

enough changes for now :)

ambrosebs19:05:20

ah to expose cross-platform extensions for vars?

borkdude19:05:28

yes

๐Ÿ‘ 1
borkdude19:05:57

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

borkdude19:05:11

as clojure vars should never be visibible directly in SCI anyway

ambrosebs19:05:31

ah, news to me!

borkdude19:05:37

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

borkdude19:05:32

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

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

borkdude19:05:58

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

borkdude19:05:08

the sci.lang.SciType one I mean

borkdude19:05:27

If you need a binary let me know

borkdude19:05:43

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

ambrosebs20:05:55

Hmm I couldn't choose ๐Ÿ™‚

borkdude10:05:28

Renamed to sci.lang.Type now

๐Ÿ‘ 1
ambrosebs02:05:09

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

borkdude10:05:14

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

๐Ÿ˜„ 1
ambrosebs13:05:54

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

borkdude13:05:20

I'll probably get back to this in the weekend