reader macro not working recursively
Closed this issue · 2 comments
gpwclark commented
using reader macro for vec inside reader macro of vec
→ (for x in '#('(7 1 9) '#(4 5 8)) (println "x is: " x "type: " (type x)))
x is: '(7 1 9)type: Pair
x is: '#(4 5 8)type: Pair
false
leaves reader macros inside vector unevaluated.
→ (for x in (vec '(7 1 9) '#(4 5 8)) (println "x is: " x " type: " (type x)))
x is: (7 1 9) type: Pair
x is: #(4 5 8) type: Vector
false
but reader macros themselves work fine.
gpwclark commented
apply this diff:
diff --git a/src/types.rs b/src/types.rs
index 458bb48..06c3fa1 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -776,7 +776,7 @@ impl Expression {
v.display_type()
}
}
- ExpEnum::Pair(_, _) => "Pair".to_string(),
+ ExpEnum::Pair(x, y) => format!("Pair( {}, {} )", x.display_type(), y.display_type()),
ExpEnum::HashMap(_) => "HashMap".to_string(),
ExpEnum::File(_) => "File".to_string(),
ExpEnum::LazyFn(_, _) => "Lambda".to_string(),
to yield:
→ (for x in '#('(7 1 9) '#(4 5 8)) (println "x is: " x "type: " (type x)))
x is: '(7 1 9)type: Pair( Symbol Pair( Pair( Int Pair( Int Pair( Int Nil ) ) ) Nil ) )
x is: '#(4 5 8)type: Pair( Symbol Pair( Vector, Nil ) )
false
gpwclark commented
not a bug