On Mon, 18 Jan 2021 12:41:45 -0800
Chris Barker via Python-Dev wrote:
>
> And in "real world" code, I've done just this -- building a system for
> saving / restoring dataclasses to/from JSON. In that case, each of the
> dataclasses knows how to save itself and build itself from JSON-compatible
>
On Mon, Nov 23, 2020 at 8:20 AM Brian Coleman
wrote:
> Take as an example a function designed to process a tree of nodes similar
> to that which might be output by a JSON parser. There are 4 types of node:
>
> - A node representing JSON strings
> - A node representing JSON numbers
> - A node
David Mertz wrote:
> On Mon, Nov 23, 2020 at 9:02 PM Brian Coleman brianfcole...@gmail.com
> wrote:
> > Basically, I
> > agree matching/destructuring is a powerful idea. But I also
> > wonder how much genuinely better it is than a library that does not
> > require
> > a language change. For
Hi Eric,
On 23/11/2020 9:32 pm, Eric V. Smith wrote:
On 11/23/2020 3:44 PM, David Mertz wrote:
I have a little bit of skepticism about the pattern matching syntax,
for similar reasons to those Larry expresses, and that Steve Dower
mentioned on Discourse.
Basically, I agree
On 11/23/2020 4:49 PM, David Mertz wrote:
On Mon, Nov 23, 2020, 4:32 PM Eric V. Smith
I just commented on Steve's post over on Discourse. The problem
with this is that the called function (m.case, here) needs to have
access to the caller's namespace in order to resolve the
On 11/23/2020 3:44 PM, David Mertz wrote:
I have a little bit of skepticism about the pattern matching syntax,
for similar reasons to those Larry expresses, and that Steve Dower
mentioned on Discourse.
Basically, I agree matching/destructuring is a powerful idea. But I
also wonder how much
On 11/23/2020 5:44 PM, David Mertz wrote:
I'd put the question this way: assuming Matcher can be written
(with a bit of stack magic), and assuming that the strings inside
m.case() calls are exactly the same mini-languague PEP 634
proposes, would you want a syntax change?
>
> I'd put the question this way: assuming Matcher can be written (with a bit
> of stack magic), and assuming that the strings inside m.case() calls are
> exactly the same mini-languague PEP 634 proposes, would you want a syntax
> change?
>
> No, I wouldn't!
>
Is one of us mixing up negations?
On 24/11/20 9:44 am, David Mertz wrote:
m = Matcher(arbitrary_expression)
if m.case("StringNode(s)"):
process_string(m.val)
elif m.case("[a, 5, 6, b]"):
process_two_free_vars(*m.values)
elif m.case("PairNone(a, b)"):
a, b = m.values
process_pair(a, b)
elif m.case("DictNode"):
On 24/11/20 9:31 am, Brian Coleman wrote:
In my opinion, the object oriented solution to this problem is to use the
visitor pattern.
Which is a good thing only if you believe that OO solutions are
always better than non-OO ones.
IMO, the visitor pattern is a workaround for when your language
On 11/23/20 1:49 PM, David Mertz wrote:
On Mon, Nov 23, 2020, 4:32 PM Eric V. Smith
I just commented on Steve's post over on Discourse. The problem with this is
that the called function (m.case, here)
needs to have access to the caller's namespace in order to resolve the
expressions, such
On Mon, Nov 23, 2020 at 08:44:21PM +, David Mertz wrote:
> Basically, I agree matching/destructuring is a powerful idea. But I also
> wonder how much genuinely better it is than a library that does not require
> a language change. For example, I could create a library to allow this:
>
> m
On Mon, Nov 23, 2020, 4:32 PM Eric V. Smith
> I just commented on Steve's post over on Discourse. The problem with this
> is that the called function (m.case, here) needs to have access to the
> caller's namespace in order to resolve the expressions, such as StringNode
> and PairNone. This is one
David Mertz wrote:
> On Mon, Nov 23, 2020 at 9:02 PM Brian Coleman brianfcole...@gmail.com
> wrote:
> > Basically, I
> > agree matching/destructuring is a powerful idea. But I also
> > wonder how much genuinely better it is than a library that does not
> > require
> > a language change. For
On Mon, Nov 23, 2020 at 9:02 PM Brian Coleman
wrote:
> > Basically, I agree matching/destructuring is a powerful idea. But I also
> > wonder how much genuinely better it is than a library that does not
> require
> > a language change. For example, I could create a library to allow this:
>
>
David Mertz wrote:
> I have a little bit of skepticism about the pattern matching syntax, for
> similar reasons to those Larry expresses, and that Steve Dower mentioned on
> Discourse.
> Basically, I agree matching/destructuring is a powerful idea. But I also
> wonder how much genuinely better it
I have a little bit of skepticism about the pattern matching syntax, for
similar reasons to those Larry expresses, and that Steve Dower mentioned on
Discourse.
Basically, I agree matching/destructuring is a powerful idea. But I also
wonder how much genuinely better it is than a library that does
Antoine Pitrou wrote:
> On Mon, 23 Nov 2020 16:15:12 -
> "Brian Coleman" brianfcole...@gmail.com
> wrote:
> > Furthermore, Python has a regular expression module
> > which implements it's own DSL for the purpose of matching string patterns.
> > Regular
> > expressions, in a similar way to
Larry Hastings wrote:
> On 11/23/20 8:15 AM, Brian Coleman wrote:
> > def process(root_node: Node):
> > def process_node(node: Node):
> > if isinstance(node, StringNode):
> > return node.value
> > elif isinstance(node, NumberNode):
> > return
On 11/23/20 12:05 PM, Chris Angelico wrote:
On Tue, Nov 24, 2020 at 7:00 AM Ethan Furman wrote:
On 11/23/20 11:06 AM, Larry Hastings wrote:
> On 11/23/20 8:15 AM, Brian Coleman wrote:
>> def process(root_node: Node):
>> def process_node(node: Node):
>> if
On Mon, Nov 23, 2020, 2:58 PM Ethan Furman
> >> if isinstance(node, StringNode):
> >> return node.value
> >> elif isinstance(node, NumberNode):
> >> return float(node.value)
> >> elif isinstance(node, ListNode):
> >> return
On Tue, Nov 24, 2020 at 7:00 AM Ethan Furman wrote:
>
> On 11/23/20 11:06 AM, Larry Hastings wrote:
> > On 11/23/20 8:15 AM, Brian Coleman wrote:
> >> def process(root_node: Node):
> >> def process_node(node: Node):
> >> if isinstance(node, StringNode):
> >> return
On 11/23/20 11:06 AM, Larry Hastings wrote:
> On 11/23/20 8:15 AM, Brian Coleman wrote:
>> def process(root_node: Node):
>> def process_node(node: Node):
>> if isinstance(node, StringNode):
>> return node.value
>> elif isinstance(node, NumberNode):
>>
On Mon, 23 Nov 2020 16:15:12 -
"Brian Coleman" wrote:
>
> Furthermore, Python has a regular expression module which implements it's own
> DSL for the purpose of matching string patterns. Regular expressions, in a
> similar way to pattern matching,
> allow string patterns to be expressed
On 11/23/20 8:15 AM, Brian Coleman wrote:
def process(root_node: Node):
def process_node(node: Node):
if isinstance(node, StringNode):
return node.value
elif isinstance(node, NumberNode):
return float(node.value)
elif isinstance(node,
25 matches
Mail list logo