Skip to content

Commit

Permalink
Print deprecation warning for ^ reader macro; refs #215
Browse files Browse the repository at this point in the history
Signed-off-by: Chouser <chouser@n01se.net>
  • Loading branch information
Chouser committed Dec 4, 2009
1 parent 20e4e45 commit b3b1fa5
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/jvm/clojure/lang/LispReader.java
Expand Up @@ -68,7 +68,7 @@ public class LispReader{
macros[';'] = new CommentReader();
macros['\''] = new WrappingReader(QUOTE);
macros['@'] = new WrappingReader(DEREF);//new DerefReader();
macros['^'] = new WrappingReader(META);
macros['^'] = new DeprecatedWrappingReader(META, "^");
macros['`'] = new SyntaxQuoteReader();
macros['~'] = new UnquoteReader();
macros['('] = new ListReader();
Expand Down Expand Up @@ -491,6 +491,26 @@ public Object invoke(Object reader, Object quote) throws Exception{

}

public static class DeprecatedWrappingReader extends AFn{
final Symbol sym;
final String macro;

public DeprecatedWrappingReader(Symbol sym, String macro){
this.sym = sym;
this.macro = macro;
}

public Object invoke(Object reader, Object quote) throws Exception{
System.out.println("WARNING: reader macro " + macro +
" is deprecated; use " + sym.getName() +
" instead");
PushbackReader r = (PushbackReader) reader;
Object o = read(r, true, null, true);
return RT.list(sym, o);
}

}

public static class VarReader extends AFn{
public Object invoke(Object reader, Object quote) throws Exception{
PushbackReader r = (PushbackReader) reader;
Expand Down

0 comments on commit b3b1fa5

Please sign in to comment.