-
Notifications
You must be signed in to change notification settings - Fork 69
Closed
Description
Describe the bug
The format-args function seems to represent strings in a weird way that messes up behavior when evaluating the output as a string. For example, parse fails to evaluate it.
Further, when called in a function, a strange hash # is appended, whereas (parse (repr $x)) return the identity as one would expect.
To Reproduce
MeTTa HE 0.2.6 via Docker. REPL.
Expected behavior
What I expected to happen: simply adding a $ before an atom to create a variable.
> !(let $x (format-args ${} (⟨t⟩)) (parse $x))
[$⟨t⟩]
> !(parse (format-args {} (⟨t⟩)))
[⟨t⟩]
> !(parse "$⟨t⟩")
[$⟨t⟩]
> !(let $x (format-args ${} (⟨t⟩)) (repr $x))
["\"$⟨t⟩\""] ;; the same as !(let $x (repr ⟨t⟩) (repr $x))
> !(let $x (format-args ${} (⟨t⟩)) (parse (repr $x)))
["$⟨t⟩"] ;; the same as !(let $x (repr ⟨t⟩) (parse (repr $x)))
> !(let $x (format-args ${} (⟨t⟩)) (parse (parse (repr $x))))
[$⟨t⟩]
> (= (make_var $x) (let $v (format-args ${} ($x)) (parse (parse (repr $v)))))
> !(make_var ⟨t⟩)
[$⟨t⟩]
> (= (make_var $x) (let $v (format-args ${} ($x)) $v))
> !(make_var ⟨t⟩)
["$⟨t⟩"]
> (= (make_var $x) (parse (repr $x)))
> !(make_var ⟨t⟩)
[⟨t⟩]
Actual behavior
What actually happened:
> !(let $x (format-args ${} (⟨t⟩)) (parse $x))
[(parse "$⟨t⟩")]
> !(parse (format-args {} (⟨t⟩)))
[(parse "⟨t⟩")]
> !(parse "$⟨t⟩")
[$⟨t⟩]
These let versions behaves as expected.
> !(let $x (format-args ${} (⟨t⟩)) (repr $x))
["\"$⟨t⟩\""]
> !(let $x (format-args ${} (⟨t⟩)) (parse (repr $x)))
["$⟨t⟩"]
> !(let $x (format-args ${} (⟨t⟩)) (parse (parse (repr $x))))
[$⟨t⟩]
Now they behave weridly with the #s.
> (= (make_var $x) (let $v (format-args ${} ($x)) (parse (parse (repr $v)))))
> !(make_var ⟨t⟩)
[(parse "$⟨t⟩#1429682")]
> (= (make_var $x) (let $v (format-args ${} ($x)) $v))
> !(make_var ⟨t⟩)
["$⟨t⟩#1430218"]
> (= (make_var $x) (parse (repr $x)))
> !(make_var ⟨t⟩)
[⟨t⟩]
Metadata
Metadata
Assignees
Labels
No labels