Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TBD: Should matching an "EMPTY rule" succeed? #34

Open
1 of 5 tasks
xparq opened this issue Sep 7, 2023 · 0 comments
Open
1 of 5 tasks

TBD: Should matching an "EMPTY rule" succeed? #34

xparq opened this issue Sep 7, 2023 · 0 comments

Comments

@xparq
Copy link
Owner

xparq commented Sep 7, 2023

First of all, what exactly an "empty rule" is, is pretty much undefined:

  • there isn't really an empty rule like {}, as it gets autoconverted to NIL. Actually: {NIL}, even...
  • should it be "" instead?! And should that be the same as {""}, too?...
  • should NIL and "" mean the same, so therefore match the same way?
  • then how about "" always matching (unanchored), while NIL was supposed to be a forced failed match (as opposed to the forced successful match of T)?!...

Since every rule is boolean, it's an unavoidable question...

  • If false (NIL), then hitting an empty rule could cancel the matching of the entire syntax, rather than just being redundant, as one might expect, and as is with the _EMPTY pattern!...

  • OTOH, in LISP, () is false (NIL).

  • Currently it's inconsistent, too: using "" would create a NIL rule, but using _EMPTY would match anything successfully.
    _Not sure which one is right... _EMPTY might actually be wanted for matching the empty string exactly, and not matching a non-empty one... So, it's ambiguous.

    • Maybe the distinction is "explicit" empty (_EMPTY) vs "implicit" empty ("")?
    • NO: The distinction is that match() by default works with substrings! So _EMPTY duly matches the empty substring of everything!
  • Anyway, there should be a straightforward and reliable way to choose to match the empty string only (in the sense that any non-empty string should not match). That should be achievable with anchoring (-> Add _END for anchoring, to reject extraneous input after a full match #21).

  • It also feels natural to have both a forced-false (NIL) and a forced-true (T) rule, so this really is a conundrum now... The empty Production kinda must be NIL (to mimic LISP), but then it would not match anything, which would be inconsistent with the empty Atom ("") matching everything...

    • Maybe it's time to recognize and separate the result of matching something from the "result" -- the intrinsic value -- of the rule that's being matched! So, matching NIL (or false, for that matter) against "anything" can still be true! But should it?... Still don't know...
@xparq xparq changed the title TBD: Should an EMPTY rule should be true or false? TBD: Should matching an "EMPTY rule" succeed? Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant