deprecation functions. Close #31

This commit is contained in:
2021-07-24 12:53:16 -06:00
parent 42f2661e4d
commit c07743d1be
3 changed files with 27 additions and 0 deletions

View File

@@ -20,6 +20,15 @@ class FieldForms {
public static function builtins() {
var map:Map<String, FieldFormFunction> = [];
function renameAndDeprecate(oldName:String, newName:String) {
var form = map[oldName];
map[oldName] = (wholeExp, args, k) -> {
CompileError.warnFromExp(wholeExp, '$oldName has been renamed to $newName and deprecated');
form(wholeExp, args, k);
}
map[newName] = form;
}
map["defvar"] = varOrProperty.bind("defvar");
map["defprop"] = varOrProperty.bind("defprop");

View File

@@ -22,6 +22,15 @@ class Macros {
public static function builtins() {
var macros:Map<String, MacroFunction> = [];
function renameAndDeprecate(oldName:String, newName:String) {
var form = macros[oldName];
macros[oldName] = (wholeExp, args, k) -> {
CompileError.warnFromExp(wholeExp, '$oldName has been renamed to $newName and deprecated');
form(wholeExp, args, k);
}
macros[newName] = form;
}
macros["load"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
wholeExp.checkNumArgs(1, 1, '(load "[file]")');
switch (args[0].def) {

View File

@@ -20,6 +20,15 @@ class SpecialForms {
public static function builtins() {
var map:Map<String, SpecialFormFunction> = [];
function renameAndDeprecate(oldName:String, newName:String) {
var form = map[oldName];
map[oldName] = (wholeExp, args, k) -> {
CompileError.warnFromExp(wholeExp, '$oldName has been renamed to $newName and deprecated');
form(wholeExp, args, k);
}
map[newName] = form;
}
map["begin"] = (wholeExp:ReaderExp, args:Array<ReaderExp>, k:KissState) -> {
// Sometimes empty blocks are useful, so a checkNumArgs() seems unnecessary here for now.