On behalf of Sean...:
On Oct 18, 2006, at 1:11 PM, Ralph Thomas wrote:
> On 10/17/06, Mat Marcus <mm...@em...> wrote:
>> Sean said he would consider adding type constraints to the model.
>
> How would this work? What would happen if there was a type violation
> -- would model throw an exception on set?
There are several ways that I've been considering (but little time to
explore) -
One option is to add attributes to cells and add an analyze pass to
the parser which would check for matching attributes and insert
runtime checks where attributes can't be determined.
Syntax for this would likely be along the lines of C/C++ except allow
for multiple types.
[number, string] cell_name <== p ? "Hello" : 20; // OK
[number] cell_name : "Hello"; // Parse Error
Here the error would be reported as an exception. Ideally I could get
the parser to construct the cell using a "type list" - this would
look something like:
add_interface_cell(@number, @std::string)(cell_name, initial_value);
And the cell would be registered with these types. A bind that didn't
match these types would fail with a cell not found. - There simply
would not be a way to attach to a cell with a type mismatch (so a
runtime error but on first connect). Using a type list interface on
the bind side this could be statically enforced on the C++ code (so
the client can't lie and claim to set a number but set a string):
set<double>(cell_name, 10.5); // looks for cell matching [number]
cell_name
-----
Another option is to do the type constraints as pure runtime checks:
cell_name where((typeof(cell_name) == @number) && (cell_name < 10))
<== 5; // OK
This would be roughly equivalent to:
cell_name <== 5;
invariant:
valid_cell <== (typeof(cell_name) == @number) && (cell_name < 10);
This is more flexible but defers catching of errors to runtime -
behavior of the check (throwing an exception vs. acting as an
invariant) needs some thought and I have to play with use cases. I'm
currently in favor of pursuing the first option as getting errors
back as early as possible is a strong goal.
Sean
>
> Ralph
>
> --
> "i have a dream and it's called a crossbar switch/what this will mean
> is no big data glitch"
>
> ----------------------------------------------------------------------
> ---
> Using Tomcat but need to do more? Need to support web services,
> security?
> Get stuff done quickly with pre-integrated technology to make your
> job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache
> Geronimo
> http://sel.as-us.falkag.net/sel?
> cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Adobe-source-devel mailing list
> Ado...@li...
> https://lists.sourceforge.net/lists/listinfo/adobe-source-devel
|