[x3d-public] Check parameters for range, enum, what else? TypeScript?

Don Brutzman brutzman at nps.edu
Tue Jun 16 18:36:34 PDT 2020


Yes stick with primary types first.  Then do Field types: SFFloat, SFVec3f, etc.  Then look at overloading with convenience methods/constructors, each programming language varies in that respect.

On 6/15/2020 8:14 PM, John Carlson wrote:
> I am checking parameters for range, enum, length, not type(s) yet, ... what else is there for setter and constructor parameter checking?
> 
> My first gulp would be to give parameters to their types, ala TypeScript.  That would be one way to solve the parameter type problem. Is it OK to convert my ES6 x3d.mjs module to TypeScript? Those who are against the coffee languages might approve.
> 
> I can see that the X3DUOM supports multiple types for parameters.

for most fields it actually is no, X3DUOM only gives a single primary type for basic (non-node) types.

For content model, sometimes it is a mix of node types and nodes that are acceptable in an SFNode/MFNode field  Also note that ProtoInstance is acceptable anywhere a node is acceptable, further type checking (i.e. is that an acceptable ProtoInstance?) has to occur in the library - usually the setter is a good place for that.

Looking at X3DJSAIL Java (Javadoc or source) and x3d.py will give examples for each and every case that you can use as exemplars to check your patterns.  They will likely be the same, just expressed a bit differently in each language.

> It looks like TypeScript allows overloading as well.
> 
> Thanks,
> 
> John

Doing TypeScript as a more rigorous/debuggable path to get towards EcmaScript certainly sounds appealing, as Cecile describes.

Hope you aren't feeling faint of heart - but it does aggregate nicely as you produce autogeneration patterns.

Good luck out there!!  8)

all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman



More information about the x3d-public mailing list