-
Notifications
You must be signed in to change notification settings - Fork 1
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
[RFC] Destructuring With Inline Transforms #5
Comments
This will definitely happen but with limit. Destructuring with match I do not see it happening within the core. simple-lang is structure in a way the VM is small and does basic operation only, high level operations will rely on libraries and functions. The following type of Destructuring will be implemented
The following will also exist with helper functions and not as a core feature
Understanding the Destructuring expression above means that for each of the characters in the string
The same result can be achieved using a function for matching the type from the string and returns the array e.g
|
Do love these example above. I believe they are apt for simple going forward. The compromise is balanced and good to go! Why not make Also, we could use standard constants to depict the type by which the variable to be destructed must be matched. The constant can be composed in form similar to a struct (as in the C language)
|
Interesting discussion here... I do have a suggestion however Drawing from your assertion @Thecarisma below,
We can borrow from Rust lang to overload the match keyword for "pattern matching" Example Rust code below: loop {
let ch = self.next()?;
match ch {
'"' | '\'' => {
}
'0' => {
}
';' => {
}
_ if ch.is_digit(10) => {
}
}
} So, the above code does pattern matching on a char variable (in a loop) and tries to do something upon a character match. We can have the below in Simple lang
|
The current standing of simple lang is that string and array variables cannot be destructured. This seeks to provide a basis for syntax to destructure string and array variables into other arrays or string variable(s) while transforming them to other data types like integer . The dollar sign in there stands as a placeholder variable for a matched type variable to be transformed.
NEW KEYWORDS:
Synergixe hopes to sponsor an RFC that changes this slightly and adds the concept of Dsetructuring with Inline transformation of data types as they are destrcutured (derived from JavaScript programming language) into the simple language.
We believe this proposition will reduce boilerplate code
What do you think ?
The text was updated successfully, but these errors were encountered: