package function.builtin;

import environment.RuntimeEnvironment;
import function.*;
import sexpression.*;

@FunctionNames({ "PRINT" })
public class PRINT extends LispFunction {

    private ArgumentValidator argumentValidator;
    private RuntimeEnvironment environment;

    public PRINT() {
        this.argumentValidator = new ArgumentValidator("PRINT");
        this.argumentValidator.setExactNumberOfArguments(1);
        this.environment = RuntimeEnvironment.getInstance();
    }

    public SExpression call(Cons argumentList) {
        argumentValidator.validate(argumentList);
        SExpression argument = argumentList.getFirst();
        environment.getOutput().println(argument);

        return argument;
    }

}
