Skip to content

Implement the anonymous variable (_) #1

Description

@bzaar

Currently one has to use unique variables if a value is to be ignored.

The benefits of having the anonymous variable include:

  1. Better readability of prolog code.
  2. Removal of runtime overhead: there is no need to bind the anonymous variable; it unifies with anything (including other anonymous variables) without causing any variables to become bound. Binding imposes some runtime cost and avoiding it removes this (possibly small) overhead.

What many other Prolog implementations do, they just generate unique names such is _G145 for each occurrence of the anonymous variable. This is undesirable because the code becomes less readable when viewed in the debugger and doing so does not remove the runtime overhead of binding those variables.

The AnonymousVariable will be another inheritor to IValue, alongside Variable and IConcreteValue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions