I have written the following macro, which defines the record with a custom string representation.
(Defmacro defrecord * [rname args] `(defrecord ~ rname [~ args] object (tostring [_] ~ ([kvs (-> & gt; Args (map) "(Str arg": ") ()") () ") ()") () ") ()") () "(str ~ rname" ("~ @ kvs"))) However, there is not enough for me to return toasting . (defrecord * Foo [bar baz] ] (.toString (Foo.34)) & gt; "Class user.Foo" (Bar: 3, Falcon: 4) " I have my toString back Foo (bar: 3, Baz: 4) In this case what changes do I need to make to represent the string in this format? In addition, if any changes are made, should I do it in the above code to make more idioms?
simply ~ rname to '~ rname' Replace with - you want the actual symbol foo , the value is not in the current radius, which is the class user.Foo . You also have (concat apply) and (interference ",") in the wrong order - as a code " , ", and a string instead of \, and \ space letters once you swap it, it becomes clear You should apply (concat (map ...) instead of mapcat ) . So I will replace your whole section like: `(str '~ rname" ("~ @ (Interpos," (mappac (faan [ag] [(str) "/"> Or if you really want to drink that performance, you can calculate ~ (str "(" rname ").) Compile-time instead of runtime On. Please note, however, that this has already been printed in such a manner as a record of Closer 1.3, so if you are doing it is easy to debugging For the sake of, do not bother. If you are doing this because you are using the output of .toString in the line later ... well, whatever the code is written to, As such, most of the stuff is for debugging.
Comments
Post a Comment