babashka-sci-dev

pfeodrippe 2022-05-02T00:38:27.198269Z

@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?).

borkdude 2022-05-09T09:07:45.844559Z

ok!

borkdude 2022-05-04T08:21:51.620819Z

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

borkdude 2022-05-04T08:21:58.700319Z

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

pfeodrippe 2022-05-04T09:10:53.167949Z

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

borkdude 2022-05-04T09:16:26.862769Z

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

borkdude 2022-05-04T09:16:43.021389Z

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

borkdude 2022-05-04T09:17:24.523299Z

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

pfeodrippe 2022-05-04T09:31:10.689629Z

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/

borkdude 2022-05-04T09:32:06.433799Z

Yes, eval-form does not depend on the parser

borkdude 2022-05-04T09:32:38.018169Z

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

pfeodrippe 2022-05-04T09:42:25.492999Z

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.

borkdude 2022-05-04T10:00:43.629439Z

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

❤️ 1
pfeodrippe 2022-05-23T00:01:32.443399Z

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!

borkdude 2022-05-02T07:01:10.182259Z

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

borkdude 2022-05-02T07:01:31.034039Z

I think that's their README

borkdude 2022-05-02T08:45:22.096209Z

@pfeodrippe 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

borkdude 2022-05-02T08:46:30.567449Z

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

borkdude 2022-05-02T08:46:50.548269Z

so I'd like to start over

pfeodrippe 2022-05-02T10:43:35.597569Z

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
borkdude 2022-05-02T10:48:52.810009Z

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

👍 1
pfeodrippe 2022-05-03T02:43:44.115829Z

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?

pfeodrippe 2022-06-19T15:48:38.158879Z

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

borkdude 2022-06-19T15:52:51.250269Z

Congrats on the moving!

pfeodrippe 2022-06-19T15:53:13.998049Z

Thanks

borkdude 2022-05-17T08:19:57.194959Z

Great progress!

pfeodrippe 2022-08-03T00:01:51.409969Z

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

borkdude 2022-05-23T10:13:48.030329Z

@pfeodrippe Excellent :) Good luck moving to Canada!

pfeodrippe 2022-05-23T10:35:59.173729Z

Thanks!

borkdude 2022-05-03T08:27:23.151919Z

@pfeodrippe 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

borkdude 2022-05-03T08:28:05.893829Z

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

👍 1
borkdude 2022-05-03T09:33:02.562539Z

@pfeodrippe @baptiste-from-paris kindly answered: > if you look at the ns cljd.test-reader.reader-test in the compiler you have examples

👏 1
pfeodrippe 2022-05-03T10:29:21.031829Z

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

pfeodrippe 2022-05-04T02:39:50.933229Z

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

pfeodrippe 2022-05-15T20:38:00.543709Z

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 🤯.

pfeodrippe 2022-05-15T20:39:02.294749Z

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

borkdude 2022-05-15T20:48:50.119329Z

Instead of instance? I believe you need to use this right? https://github.com/Tensegritics/ClojureDart/blob/main/doc/differences.md#no-instance

borkdude 2022-05-15T20:49:29.747189Z

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

pfeodrippe 2022-05-15T20:59:13.134979Z

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
borkdude 2022-05-15T20:59:54.218089Z

Can I follow this work in a repo somewhere?

pfeodrippe 2022-05-15T21:02:53.210669Z

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
pfeodrippe 2022-05-15T21:03:21.260499Z

It lets you know what you are missing

borkdude 2022-08-03T09:40:52.052759Z

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

❤️ 1
pfeodrippe 2022-05-17T01:51:20.769369Z

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
pfeodrippe 2022-05-09T00:11:53.225219Z

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;

...
...
...

pfeodrippe 2022-05-02T03:11:43.855419Z

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