Skip to content

Commit b3b1fa5

Browse files
committed
Print deprecation warning for ^ reader macro; refs #215
Signed-off-by: Chouser <[email protected]>
1 parent 20e4e45 commit b3b1fa5

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/jvm/clojure/lang/LispReader.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class LispReader{
6868
macros[';'] = new CommentReader();
6969
macros['\''] = new WrappingReader(QUOTE);
7070
macros['@'] = new WrappingReader(DEREF);//new DerefReader();
71-
macros['^'] = new WrappingReader(META);
71+
macros['^'] = new DeprecatedWrappingReader(META, "^");
7272
macros['`'] = new SyntaxQuoteReader();
7373
macros['~'] = new UnquoteReader();
7474
macros['('] = new ListReader();
@@ -491,6 +491,26 @@ public Object invoke(Object reader, Object quote) throws Exception{
491491

492492
}
493493

494+
public static class DeprecatedWrappingReader extends AFn{
495+
final Symbol sym;
496+
final String macro;
497+
498+
public DeprecatedWrappingReader(Symbol sym, String macro){
499+
this.sym = sym;
500+
this.macro = macro;
501+
}
502+
503+
public Object invoke(Object reader, Object quote) throws Exception{
504+
System.out.println("WARNING: reader macro " + macro +
505+
" is deprecated; use " + sym.getName() +
506+
" instead");
507+
PushbackReader r = (PushbackReader) reader;
508+
Object o = read(r, true, null, true);
509+
return RT.list(sym, o);
510+
}
511+
512+
}
513+
494514
public static class VarReader extends AFn{
495515
public Object invoke(Object reader, Object quote) throws Exception{
496516
PushbackReader r = (PushbackReader) reader;

0 commit comments

Comments
 (0)