cherry

armed 2022-08-07T07:05:08.267939Z

Is function returning a function is not here yet? (I guess I found a bug maybe)

(defn my-fun []
  (fn [] "foo"))
evaluates to
var my_fun = function () {
  function () {
    return "foo";
  }
};

armed 2022-08-07T07:09:07.193379Z

(defn ^:async my-fun [url]
  (js/await (js/fetch url)))
evaluates to:
var my_fun = async function (url) {
  (await return fetch(url);)
};
but should be something like
var my_fun = async function (url) {
  return await fetch(url)
};

armed 2022-08-07T07:11:20.160299Z

wrapping in let block is a workaround atm

borkdude 2022-08-07T07:12:24.637859Z

ah, this is a bug, can you make an issue?

👍 1
armed 2022-08-07T07:13:10.982029Z

sure

armed 2022-08-07T07:17:15.800669Z

done: https://github.com/borkdude/cherry/issues/44 Awesome project, by the way. Love it ❤️

borkdude 2022-08-07T07:27:25.271809Z

Thanks

borkdude 2022-08-07T09:48:37.603519Z

Fixed in 0.0.0.alpha.43

armed 2022-08-07T09:57:39.055049Z

cool, thanks. Sorry for bothering again, but is this a bug? following code:

(def arr #js [1 2 3])
compiles to
var arr = vector(1, 2, 3);

borkdude 2022-08-07T09:59:11.173639Z

This is a bug. Not bothering at all, thanks for finding the intial bugs - we need more people like you test-driving this

🍻 1
armed 2022-08-07T09:59:50.963499Z

ok I’ll create an issue

armed 2022-08-07T10:01:56.455169Z

https://github.com/borkdude/cherry/issues/45

borkdude 2022-08-07T10:14:17.344769Z

fixed in v45

👍 1
armed 2022-08-07T10:33:13.580449Z

Not sure if is it in the plans to add this behavior, but keywords are not treated as ifn in map lookups:

(def foo (:name {:name "Joe"}))
compiles to:
var foo = keyword("name")(arrayMap(keyword("name"), "Joe"));

borkdude 2022-08-07T10:36:02.096619Z

yes, should also be fixed

armed 2022-08-07T10:37:51.592309Z

nice, https://github.com/borkdude/cherry/issues/46

borkdude 2022-08-07T11:01:46.731469Z

fixed

👍 1
borkdude 2022-08-07T11:08:46.381249Z

v45

borkdude 2022-08-07T11:08:51.000869Z

eh

borkdude 2022-08-07T11:09:01.433879Z

no gotta release still

borkdude 2022-08-07T11:10:27.240969Z

v46 released

armed 2022-08-07T11:10:46.807349Z

neat

armed 2022-08-07T11:14:17.623399Z

By the way, how to prevent cljs watch task to fail? for example if I save a file with unbalanced parens, it prints an error:

Node.js v18.2.0
#error {
 :cause "Error while executing task: watch-cljs"
 :data {:proc {:proc #object[java.lang.ProcessImpl 0x5e94a421 "Process[pid=72043, exitValue=1]"], :exit 1, :in #object[java.lang.ProcessBuilder$NullOutputStream 0xa1c136c "java.lang.ProcessBuilder$NullOutputStream@a1c136c"], :out #object[java.lang.ProcessBuilder$NullInputStream 0x4adce46e "java.lang.ProcessBuilder$NullInputStream@4adce46e"], :err #object[java.lang.ProcessBuilder$NullInputStream 0x4adce46e "java.lang.ProcessBuilder$NullInputStream@4adce46e"], :prev nil, :cmd ["node" "node_modules/.bin/cherry" "index.cljs"]}, :task #'babashka.tasks/*task*, :babashka/exit 1}
 :via
 [{:type clojure.lang.ExceptionInfo
   :message "Error while executing task: watch-cljs"
   :data {:proc {:proc #object[java.lang.ProcessImpl 0x5e94a421 "Process[pid=72043, exitValue=1]"], :exit 1, :in #object[java.lang.ProcessBuilder$NullOutputStream 0xa1c136c "java.lang.ProcessBuilder$NullOutputStream@a1c136c"], :out #object[java.lang.ProcessBuilder$NullInputStream 0x4adce46e "java.lang.ProcessBuilder$NullInputStream@4adce46e"], :err #object[java.lang.ProcessBuilder$NullInputStream 0x4adce46e "java.lang.ProcessBuilder$NullInputStream@4adce46e"], :prev nil, :cmd ["node" "node_modules/.bin/cherry" "index.cljs"]}, :task #'babashka.tasks/*task*, :babashka/exit 1}
   :at [babashka.impl.tasks$handle_non_zero invokeStatic "tasks.clj" 50]}]
 :trace
 [[babashka.impl.tasks$handle_non_zero invokeStatic "tasks.clj" 50]
  [babashka.impl.tasks$shell invokeStatic "tasks.clj" 87]
  [babashka.impl.tasks$shell doInvoke "tasks.clj" 59]
  [clojure.lang.RestFn invoke "RestFn.java" 423]
  [sci.lang.Var invoke "lang.cljc" 169]
  [sci.impl.analyzer$return_call$reify__5178 eval "analyzer.cljc" 1192]
  [sci.impl.analyzer$return_if$reify__4891 eval "analyzer.cljc" 660]
  [sci.impl.evaluator$eval_let invokeStatic "evaluator.cljc" 71]
  [sci.impl.analyzer$analyze_let_STAR_$reify__4844 eval "analyzer.cljc" 505]
  [sci.impl.fns$fun$arity_1__3491 invoke "fns.cljc" 106]
  [sci.impl.analyzer$return_binding_call$reify__5053 eval "analyzer.cljc" 1110]
  [sci.impl.fns$fun$arity_1__3491 invoke "fns.cljc" 106]
  [babashka.pods.impl$processor invokeStatic "impl.clj" 231]
  [babashka.pods.sci$load_pod$fn__27096 invoke "sci.clj" 121]
  [sci.impl.vars$binding_conveyor_fn$fn__395 invoke "vars.cljc" 129]
  [clojure.core$binding_conveyor_fn$fn__5823 invoke "core.clj" 2047]
  [clojure.lang.AFn call "AFn.java" 18]
  [java.util.concurrent.FutureTask run "FutureTask.java" 264]
  [java.util.concurrent.ThreadPoolExecutor runWorker "ThreadPoolExecutor.java" 1128]
  [java.util.concurrent.ThreadPoolExecutor$Worker run "ThreadPoolExecutor.java" 628]
  [java.lang.Thread run "Thread.java" 829]
  [com.oracle.svm.core.thread.PlatformThreads threadStartRoutine "PlatformThreads.java" 704]
  [com.oracle.svm.core.posix.thread.PosixPlatformThreads pthreadStartRoutine "PosixPlatformThreads.java" 202]]}
:repl/quit
and then does not recover, only restart fixes it

armed 2022-08-07T11:14:33.918039Z

I use watch bb task from react example

borkdude 2022-08-07T11:16:39.232329Z

the react example doesn't have a bb.edn - can you be more specific, e.g. link to the specific file you're talking about?

armed 2022-08-07T11:23:39.331429Z

Ah, right, by bad. I’m using vite example actually. https://github.com/borkdude/cherry/tree/main/examples/vite

borkdude 2022-08-07T11:24:44.211139Z

should be fixed now

armed 2022-08-07T11:24:53.846379Z

wow, cool

borkdude 2022-08-07T15:52:45.668039Z

@thheller did some experiments with ES module, but unfortunately, binding in cljs.core generates a direct re-assignment of vars the were imported which isn't valid JS... https://github.com/thheller/shadow-cljs/commit/e8e0cf9973bafcd472ffa1066bbd8ae8c83e5cab

borkdude 2022-08-07T19:43:17.419569Z

A browser version of cherry: Very basic UI, wrote the index.html in a few minutes, cherry is loaded from npm via import-maps. https://borkdude.github.io/cherry/index.html

🍒 3
🌸 1
🤯 1
4
🙀 2
🎉 1