August 05, 2007 Re: MiniD 1.0 released! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Jarrett Billingsley wrote: > "Christopher Wright" <dhasenan@gmail.com> wrote in message news:f926br$2a08$1@digitalmars.com... >> Is there any chance of support for optional strong typing? That's my main beef with Javascript; the one time I've used it for a production system, it took six hours to do something that would have been fifteen minutes with strong typing (due to a single bug), and I never did accomplish what I set out to do. >> >> At least function arguments should be typed, or typeable, in an object-oriented language. Lua doesn't need strong typing as much because it only has primitives, functions, and tables. But MiniD is object-oriented, and the only alternative to typing is reflection.[1] Maybe some sort of 'where' clause? >> function do_stuff(arg1, arg2) where arg2 : ExpectedClass {} > > I think you must have been reading my personal design notes :) Function parameter type constraints is a feature I've been considering for v2.0. They'd look something like this: > > function f(x : int, y : !int, z : int | float, w : instanceof Foo) { ... } > > x : int means only ints are allowed; y : !int means anything _but_ ints; z : int | float means z can take an int or a float, and w : instanceof Foo means it has to be an instance of class Foo (or any class derived from it). This looks very nice to me. Actually, the internal language for a project of mine does something slightly similar. (I hadn't accounted for the case you solve with ": int|float"... might have to borrow that. And the last case would be just ": #Foo".) -- Chris Nicholson-Sauls |
August 05, 2007 Re: MiniD 1.0 released! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Christopher Wright | For reference, ecmascript v4 (aka Javascript 2) specifications allows a 'strict' mode where all sorts of type definitions can be defined and caught by the compiler / runtime etc.
It's not a high priority for me working on dmdscript, but I am using that as the roadmap... (I already have class syntax though and have fixed the scoping issues with the original code)..
Regards
Alan
Christopher Wright wrote:
> Jarrett Billingsley wrote:
>> After more than a year of brainstorming, writing, re-writing, taking ideas from other languages and generally having a good time, I've come to what I feel is a good place to call it 1.0.
>>
>> == What is MiniD? ==
>>
>> MiniD is a scripting language written entirely in D, designed around D's features and with D's semantics in mind. It's based mainly off of Lua and Squirrel, with influences from D and JavaScript.
>
> Is there any chance of support for optional strong typing? That's my main beef with Javascript; the one time I've used it for a production system, it took six hours to do something that would have been fifteen minutes with strong typing (due to a single bug), and I never did accomplish what I set out to do.
>
> At least function arguments should be typed, or typeable, in an object-oriented language. Lua doesn't need strong typing as much because it only has primitives, functions, and tables. But MiniD is object-oriented, and the only alternative to typing is reflection.[1] Maybe some sort of 'where' clause?
> function do_stuff(arg1, arg2) where arg2 : ExpectedClass {}
>
> -cbw
>
> [1] And that's rather ugly and long-winded:
> if (!is (typeof(argument) == ExpectedClass))
> assert(false);
|
Copyright © 1999-2021 by the D Language Foundation