Can you clarify? This is meant to be reeeeally close to how current JS destructuring works. The difference is some extra matching-related syntax. Guards exist exclusively at the toplevel.
-
-
Replying to @maybekatz @wycats
I agree that deeply nested destructuring is a pain pretty much no matter what you do -- I think the utility of this is simplifying navigating 1- or 2-levels that often turn into `if` statements with stuff like `if (foo && http://foo.bar && foo.baz === 1)` etc
3 replies 0 retweets 7 likes -
Replying to @maybekatz
Yeah I think this example illustrates the one level use cases nicely. Would this syntax differentiate between undefined and missing? In other words, would a prop with undefined as a value match, while a missing prop wouldn't?
1 reply 0 retweets 1 like -
Replying to @wycats
the short version: yes! Matcher keys mentioned makes their presence required (w/ .hasOwnProperty()). Primitive literals are (currently) matched `===`. Long version: I spent most of today writing up a rough implementaion + documenting a bunch of details:https://github.com/zkat/pattycake
1 reply 0 retweets 5 likes -
Replying to @maybekatz
I wonder if that could be a footgun with forwarded undefined (and inconsistent with defaults in destructuring: let { x: x = 1 } = { x: undefined } x // 1
1 reply 0 retweets 2 likes -
Replying to @wycats
Idk. I hadn't looked too closely at what current destructing does. If undefined is what default values actually check against, that seems a better solution. Would you care to PR that?
I'm heading to bed in a sec1 reply 0 retweets 2 likes -
Replying to @maybekatz
No problem! I can at least open an issue, depending on how hard the current language is to modify. Link?
1 reply 0 retweets 1 like -
Replying to @wycats
Up the thread! I'm gonna see about replacing the existing match proposal with this one once I've incorporated some missing bits for the original and the champions give their blessing. If it works out that way
https://github.com/zkat/pattycake 1 reply 0 retweets 1 like -
Replying to @maybekatz
I was working with
@bterlson on match a while ago. Is that the proposal you're talking about?1 reply 0 retweets 0 likes -
Yup! I'm working with him now on irc and he encouraged me to pick this up. I'm trying to make sure all the bits he wanted are there
1 reply 0 retweets 3 likes
Great! Excited that you'll be picking this up. It could use some dedicated effort pushing it.
-
-
There's also https://github.com/elixirscript/tailored …, inspired by
@elixirlang0 replies 0 retweets 1 likeThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.