Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Proper pattern matching #12

Open
WilliamRagstad opened this issue Jan 31, 2022 · 0 comments
Open

Proper pattern matching #12

WilliamRagstad opened this issue Jan 31, 2022 · 0 comments
Labels
↻ breaking Suggestions or fixes that are breaking changes in some way. • enhancement New feature or request ∆ feature New feature suggestion # prioritize Issues that are more urgent than others

Comments

@WilliamRagstad
Copy link
Member

Currently the = operator is more of a naive "statementy" expression verifying that the variable in an assignment isn't already defined in the global scope. This has also caused problems such as #1.

The features suggested in this issue is to move towards the functional idea of the = operator. Meaning allowing LHS and RHS to be swapped at will (symmetric property), but most importantly the implementation must be compatible with #11.

The desired functionality would be:

  • Comparison
    a = 10 # true, side-effect: a is defined
    a = 10 # true, no side-effect
    5 * 2 = a # true, no side-effect
    b = 80
    c = b / 2 = a * 4 # true, side-effect: c is defined
    3.1415926535 = c / a # false (nice try tho)
  • Variable scope shadowing Variable scope shadowing #2
    a = 10 # true, side-effect: a is defined in global scope
    a = 42 # false
    {
      a = 42 # true, side-effect: a is defined in local scope, shadow parent scope
    }
  • Destructuring with recursive pattern matching
    [a, 10, b | [(42, c), tail]] = [-2, 10, 25, (42, "Hello"), 0]
    # a = -2, b = 25, c = "Hello" and tail = [0] 
  • Reverse concatination
    firstname + " " + lastname = "John Doe"
    # firstname = "John" and lastname = "Doe"
  • Basic reverse aritmetics (for non-ambigious, single "answer" expressions. Not meaning + life = 42)
    a = 1000
    b ^ 3 = a
    # b = 10

More suggestions may come, this list is not complete.

@WilliamRagstad WilliamRagstad added • enhancement New feature or request ∆ feature New feature suggestion # prioritize Issues that are more urgent than others labels Jan 31, 2022
@WilliamRagstad WilliamRagstad added the ↻ breaking Suggestions or fixes that are breaking changes in some way. label Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
↻ breaking Suggestions or fixes that are breaking changes in some way. • enhancement New feature or request ∆ feature New feature suggestion # prioritize Issues that are more urgent than others
Projects
None yet
Development

No branches or pull requests

1 participant