Fork me on GitHub
#babashka-sci-dev
<
2022-05-02
>
pfeodrippe00:05:27

@borkdude About SCI ClojureDart support (https://github.com/babashka/sci/issues/718), let me know if you have tried something already. Otherwise I can try to dig into the code during the nights of this week to see what you had to do to support both CLJ and CLJS (in a first view, it seems they are much more alike to each other than ClojureDart is, is this true?).

pfeodrippe03:05:43

Ok, checked here, lots of errors ahahaha, no extend-protocol (but it seems to be a easy macro to do as extend-type already exists), no instance? (existing issue), among others. Will take another look tomorrow

borkdude07:05:10

Should we set up a branch to develop in? Instance? Is replaced by something else in cljd

borkdude07:05:31

I think that's their README

borkdude08:05:22

@U5R6XUARE I have a branch clojure-dart in SCI now, maybe you can start making incremental PRs against that branch and we can discuss each step

borkdude08:05:30

I have tried something previously but I haven't saved that code anywhwre

borkdude08:05:50

so I'd like to start over

pfeodrippe10:05:35

Nice, thanks, Michiel! I've copied the SCI code to a local dart starter project, but I can put it in this branch tonight o/ Let's iterate

👍 1
borkdude10:05:52

We can decide to just not support features if the ClojureDart host doesn't yet support them, like multi-methods

👍 1
pfeodrippe02:05:44

I'm trying to make something work at https://github.com/pfeodrippe/sci-test/compare/test?expand=1 (after I get something working, I can push to sci). The approach I am trying is a little fuzzy, just doing whatever is needed to make it work (at least compiling green) on top of the existing SCI code (but acting as if other languages didn't exist) and later we can reconcile it with the existing codebase. I find it easier to find big roadblocks this way. BTW, clojure.tools.reader (reader types ns) seems to be one of these. I will check if we will need to use something completely different or if we can make it work by adding a third env (cljd) to https://github.com/clojure/tools.reader. Thinking further, do you think edamame will be a big pain?

borkdude08:05:23

@U5R6XUARE What does cljd use to read forms? It may not have a reader at the level of .cljd yet? If so, then that's the first major roadblock, I guess

borkdude08:05:05

In the sci.parser namespace we could switch to something else than edamame, if cljd has a reader we can use

👍 1
borkdude09:05:02

@U5R6XUARE @U2N9GDB1U kindly answered: > if you look at the ns cljd.test-reader.reader-test in the compiler you have examples

👏 1
pfeodrippe10:05:21

Nice, thanks, Michiel and Baptiste! Will take a look tonight

pfeodrippe02:05:50

Ok, have been able to compile* a a part of cljd tools reader that SCI uses (https://github.com/pfeodrippe/sci-test/compare/test?expand=1#diff-1e53ca04b5396136017113fcfbd2c9ea66fe71626a43f80e8bc6abf3b4e5f605), tomorrow or the next day I will start focusing in some edamame-ish code (`sci.impl.parser`). *It's green, but there are some dynamic warnings, I will deal with them later

borkdude08:05:51

@U5R6XUARE Awesome. The files you've copied, are they part of clojuredart?

borkdude08:05:58

If so, we could just re-use them from there?

pfeodrippe09:05:53

No, they are not, I'm following their repo for new changes o/ There is only a https://github.com/Tensegritics/ClojureDart/blob/main/clj/src/cljd/reader.cljd that we certainly can use inside the tools reader namespaces. The files there are the SCI namespaces + whatever namespaces from other libraries are needed to make it compile. After everything is green, we can fix the rough bits, take it to the SCI repo, remove non-applicable parts (like defmethoda) and let the tests talk by themselves

borkdude09:05:26

@U5R6XUARE We could also focus on just making eval-form work

borkdude09:05:43

and then use the reader that comes with clojure-dart - unless I'm not understanding things correctly

borkdude09:05:24

but I'm fine with either approach in this experimental phase :)

pfeodrippe09:05:10

Yes yes, I will check that, thanks! This one does not depends on the parser (so no need for clojure tools reader or edamame for these?), right? At least not directly in the interpreter ns. Let me know of other low-hang fruits if you remember o/

borkdude09:05:06

Yes, eval-form does not depend on the parser

borkdude09:05:38

not sure if the namespace organization still requires this, but we can probably do something about that

pfeodrippe09:05:25

Awesome! The only thing a little bit hard to read are the interleaved reader conditionals in cljc files for the same form (specially inside defrecord or deftypes), but this is Clojure's fault and, in the end, it becomes less code to maintain. I wish I had more than 1 or 2 hours per day to work on this ahahahahah SCI is such a great project.

borkdude10:05:43

@U5R6XUARE Let's take our time, SCI-dart summer of code ;)

❤️ 1
pfeodrippe00:05:53

Have been able to compile the code for eval-form, now will try to solve the errors when I try to run it (it should be related to the build warnings)

➜  dartapp git:(test) ✗ dart run

Building package executable...
Failed to build dartapp:dartapp:
lib/cljd-out/sci/impl/vars.dart:250:12: Error: A method declaration needs an explicit list of parameters.
Try adding a parameter list to the method declaration.
dc.dynamic clojure.core/meta(){
           ^^^^^^^
lib/cljd-out/sci/impl/vars.dart:250:24: Error: Expected '{' before this.
dc.dynamic clojure.core/meta(){
                       ^
lib/cljd-out/sci/impl/vars.dart:250:12: Error: The name of a constructor must match the name of the enclosing class.
dc.dynamic clojure.core/meta(){
           ^^^^^^^
lib/cljd-out/sci/impl/vars.dart:250:1: Error: Constructors can't have a return type.
Try removing the return type.
dc.dynamic clojure.core/meta(){
^^
lib/cljd-out/sci/impl/vars.dart:250:24: Error: Operator declarations must be preceded by the keyword 'operator'.
Try adding the keyword 'operator'.
dc.dynamic clojure.core/meta(){
                       ^
lib/cljd-out/sci/impl/vars.dart:250:24: Error: A method declaration needs an explicit list of parameters.
Try adding a parameter list to the method declaration.
dc.dynamic clojure.core/meta(){
                       ^
lib/cljd-out/sci/impl/vars.dart:250:25: Error: Expected '{' before this.
dc.dynamic clojure.core/meta(){
                        ^^^^
lib/cljd-out/sci/impl/vars.dart:250:24: Error: Operator '/' should have exactly one parameter.
dc.dynamic clojure.core/meta(){
                       ^
lib/cljd-out/sci/impl/vars.dart:250:25: Error: 'meta' is already declared in this scope.
dc.dynamic clojure.core/meta(){
                        ^^^^
lib/cljd-out/sci/impl/vars.dart:238:7: Context: Previous declaration of 'meta'.
final meta;

...
...
...

pfeodrippe20:05:00

Trying to workaround some ClojureDart issues, see https://github.com/Tensegritics/ClojureDart/issues/70 and https://github.com/Tensegritics/ClojureDart/issues/69 (this one for reflection), #70 was 🤯.

pfeodrippe20:05:02

I have been able to eval constants for now (do 3) => 3 haeuaehuheuheau not very interesting

borkdude20:05:29

It's great that you're uncovering ClojureDart edge cases this way!

pfeodrippe20:05:13

Yes, I'm trying to create a custom instance? for SCI just to make it work. dart/is? does not receive accept dynamic class (it has to be known at compile time), this is why I'm checking if it's possible to use dart:mirrors for reflection for now, let's see if it works o/

👍 1
borkdude20:05:54

Can I follow this work in a repo somewhere?

pfeodrippe21:05:53

You can see at https://github.com/pfeodrippe/sci-test/compare/test?expand=1 o/ Making SCI work should be the target for every new Clojure runtime from now on ahahahaah

👍 1
pfeodrippe21:05:21

It lets you know what you are missing

pfeodrippe01:05:20

Now we can parse simple expressions!!!

(ns quickstart.helloworld
  (:require
   [sci.core :as sci]))

(defn main []
  (println (sci/eval-form (sci/init {})
                          '(+ 1 2))
           "\n"
           (sci/eval-form (sci/init {})
                          '(+ 4 (- 5 1)))
           "\n"
           (sci/eval-form (sci/init {})
                          '(-> (- 5 1)
                               (+ 4)
                               (* 2)
                               (+ 10)))))

;; =>
;; 3
;; 8
;; 26

🎉 1
borkdude08:05:57

Great progress!

pfeodrippe00:05:32

I've opened https://github.com/pfeodrippe/sci/pull/1 and will be updating there (it's using an old src/sci commit, but we can update when this is working). For these next 3 weeks, I will be moving from Brazil to Canada, so things will probably be slower, but I will try to advance as much as I can, it's exciting!

borkdude10:05:48

@U5R6XUARE Excellent :) Good luck moving to Canada!

pfeodrippe15:06:38

Now I'm more settled here and will be able to start again, right away just bumped at some Dart compilation problem haeuaheuahue will try to figure out what's happening to open an GH issue

borkdude15:06:51

Congrats on the moving!

pfeodrippe00:08:51

Sorry man, couldn't do anything these days, still trying to figure things out here :/

borkdude09:08:52

@U5R6XUARE Oh no problem at all! There is absolutely no pressure from my side :-)

❤️ 1