Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defmacro compile time STDOUT generates Dart code #70

Closed
pfeodrippe opened this issue May 15, 2022 · 0 comments
Closed

defmacro compile time STDOUT generates Dart code #70

pfeodrippe opened this issue May 15, 2022 · 0 comments

Comments

@pfeodrippe
Copy link
Contributor

pfeodrippe commented May 15, 2022

This one was a little hard to understand what was going on.

If I print something (e.g. with println) inside a defmacro (and the macro compilation is for a deftype (but it may occur for other cases)), the STDOUT goes to the generated code.

(ns example)

(defmacro instance?
  []
  (println '(1 + 4)))

(deftype SciVar []
  Object
  (toString [_]
    (not (instance?))))

throws

✗ dart run

Building package executable...
Failed to build dartapp:dartapp:
lib/cljd-out/quickstart/helloworld.dart:16:1: Error: Expected an identifier, but got '('.
Try inserting an identifier before '('.
(1 + 4)
^

The generated code is something like

... imports ...

// BEGIN SciVar
class SciVar extends dc.Object {

const SciVar():super();
(1 + 4)     // <-- _O_ !!!!!!!!!!!!!!!!!!!!!

dc.String toString(){
return true;
}
}

// END SciVar

// BEGIN instance?
dc.dynamic instance$QMARK_(dc.dynamic $AMPERSAND_form$1, dc.dynamic $AMPERSAND_env$1, ){
final dc.List<dc.dynamic> fl$1=(dc.List<dc.dynamic>.filled(3, 1, ));
fl$1[1]=(Upfddlcoc_core.symbol.$_invoke$2(null, "+", ));
fl$1[2]=4;
final Upfddlcoc_core.PersistentList $1=Upfddlcoc_core.$_list_lit(fl$1, );
return (Upfddlcoc_core.println.$_invoke$1($1, ));
}

// END instance?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant