On 26/03/2007, at 4:39 AM, Octave Julien wrote:
>
> Le 25 mars 07, à 07:22, Andy Dent a écrit :
>> You may want to rethink your design then. Why does one particular
>> script require such a broad interface - could the logic be broken
>> down into multiple scripts?
>
> I dont think so. One single line of code in the script source must be
> able to deal with several different objects, in a command like
> someObject.someNumProperty=len(someOtherObject.someStringProperty)
That code doesn't seem very user-friendly to me :-)
Scripts should be written from the user point of view - you are
creating a domain-specific language for their benefit.
Are your users really sufficiently sophisticate that they want an OO
view?
I've used RBScript for graphics and Python for adding formulas to a
scientific C++ app (for an audience that includes people who use
Python in an OO sense elsewhere) and in neither case does what goes
into a script require that degree of sophistication.
> an object defined and instantiated in a
> script would disappear as soon as the script is over, right ?
yep
> I can imagine a possible workaround from the top of my head : to
> define classes within the script where the constructor automatically
> creates a reference to its new instance in a property of the
> application. Then, the script would include a portion of code that
> creates a new copy of these instances to make them available to the
> script. Another portion of code would 'refresh' on the app side the
> image of objects used.
That's a very clear explanation of an approach that would work, if
you really really want to have objects in the user script :-)
Remember that you can't pass objects across the edge of the sandbox
so your 'persistence' calls would have to store the state either in a
single string or make a series of calls.
When it comes to defining stuff before the user code, you can even
add functions to the builtin types, using the extends syntax, eg:
' could be before user code
module stringers
Function left3(extends s as string) as string
return left(s, 3)
End Function
end module
' possible user code
dim s as string = "Hi Joe"
drawstring s.left3 ,10,100
regards
Andy
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>