[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] Penlight 1.3 Request for Comment
- From: Andrew Starks <andrew.starks@...>
- Date: Sat, 14 Sep 2013 09:12:02 -0500
Last email (hopefully :) ) is on type:
Your approach has been to provide libraries that COULD be monkey patches, but are not. tablex and stringx being primary examples.
I would love to see such a library for type (typex), especially if it replaced pl.class's system. Imagine a type system which ape'd (monkeys and apes) LPeg's syntax:
If this_thing == animal + plant + mineral then ...
P = pl.typex.P
my_argument_list = P"string" * P(1)^1my_args2 = (P"number" + P(1) / tonumber) * (P"my_object" + my_obj_init_args /my_object._init)
(Any further examples would include back tracing...)
You can imagine how these type patterns might also contain class definitions, such that you could construct objects by calling the type object with the correct arguments (if any).
Also, imagine applying function types by making types pattern for the arguments and to the return value and then (optionally) wrapping functions/fun tables/coroutines. You could then query the type of the function. Flip a flag to "off" so that this wrapping didn't happen when you weren't testing. For myself, I would do all of my argument checking with this, so anything with a public interface would be wrapped, at least for arguments, if not return values.
This is a thought that I've been playing with, which is why I state it here. I don't so much feel it be belongs in an x.y release.
I'll spare you my 4th email, which was going to be on ranges. :)