Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
LoxList
, one for representing theappend()
method and the other for thedeleteAt()
method, both of which implementLoxCallable
and are instantiated and returned when the correspondentLoxList
property is retrieved. The two inner classes are passed a reference to the outerLoxList
instance such that they can access/mutate its elements.standardLibrary
string previously defined inInterpreter
is no longer needed, as all necessary plumbing is centralized inLoxList
, and so there is no more hiddenList
class to instantiate. Perhaps in the future, we can reinstate it when we build things on top of existing infrastructure instead of being foundational but needing to access features in the Swift layer that are not expressible in Lox code.List
class, there is no need forappendNative
anddeleteAtNative
cases inNativeFunction
LoxValue
enum now has acallable
case for a third class of functions, for the time being to represent methods of a specialized Lox class. The other two extant cases just didn't quite work:UserDefinedFunction
, although gets passed anEnvironment
through its constructor, also needs to be passedResolvedStatement
s as its body, which would be awkward to express in the interpreter when bootstrapping. Moreover, there is no way to express new language features in Lox itself, which is the central to the problem we're trying to solve.NativeFunction
does not have access to an environment and thus no way to get a handle to the instance whose method is being invoked. It really is intended to represent a standalone function likeclock()
. It also didn't make sense to add aklass
property toNativeFunction
since it would be nonsensical for things likeclock()
which are not bound to a class.callable
case intoLoxValue
, I needed to be able to have the latter conform toEquatable
explicitly. This conformance is only meaningful in the context of a unit test, in which I need to be able to compare ASTs in many cases.