On Mon, Nov 16, 2015 at 6:07 AM, Harbs <harbs.li...@gmail.com> wrote:
> It would actually be very nice if there was some way to (optionally) > prevent null being passed into constructors and function calls. There has > been more than once that I would have liked to have that feature. > > I wonder if that’s something we can add to Falcon? > It could be done but there would have to be some kind of config either in the compiler args or @param tag like @param arg0 !null Foo desc, or metadata tag with param names for not null params. The AST has the null identifier and you can tell if it's being passed in a Function/Method call at compile time. Mike > > On Nov 16, 2015, at 12:43 PM, Michael Schmalle <teotigraphix...@gmail.com> > wrote: > > > On Mon, Nov 16, 2015 at 5:40 AM, OmPrakash Muppirala < > bigosma...@gmail.com> > > wrote: > > > >> Nope, you can still call new Singleton(null) and the compiler won't say > >> anything :-) > >> The 'enforcer' is required because of this loophole. > >> > >> > > Yeah, you're right, to early in the morning.. :) > > > > > >> Thanks, > >> Om > >> > >> On Mon, Nov 16, 2015 at 2:36 AM, Michael Schmalle < > >> teotigraphix...@gmail.com > >>> wrote: > >> > >>> On Mon, Nov 16, 2015 at 4:14 AM, OmPrakash Muppirala < > >> bigosma...@gmail.com > >>>> > >>> wrote: > >>> > >>>> Purely pedantic, but the code does not do anything to 'enforce' the > >>>> singleton-ness of the class. > >>>> > >>> > >>> The compiler won't even let you compile this code, so the != is just > >> sauce > >>> that never gets eaten. Since you have to pass an instance of > >>> SingletonEnforcer, it's private and the compiler will bitch. > >>> > >>> Mike. > >>> > >>> > >>>> > >>>> It should actually be: > >>>> public function Singleton(e:SingletonEnforcer){ > >>>> if(e != null) > >>>> { > >>>> trace("new instance of singleton created"); > >>>> } > >>>> } > >>>> > >>>> On Mon, Nov 16, 2015 at 12:54 AM, yishayw <yishayj...@hotmail.com> > >>> wrote: > >>>> > >>>>> Actually the comment above 'class SingletonEnforcer' explains it. > >>>>> > >>>>> package{ > >>>>> public class Singleton{ > >>>>> private static var _instance:Singleton=null; > >>>>> public function Singleton(e:SingletonEnforcer){ > >>>>> trace("new instance of singleton created"); > >>>>> } > >>>>> public static function getInstance():Singleton{ > >>>>> if(_instance==null){ > >>>>> _instance=new Singleton(new SingletonEnforcer()); > >>>>> } > >>>>> return _instance; > >>>>> } > >>>>> } > >>>>> } > >>>>> //I’m outside the package so I can only be accessed internally > >>>>> class SingletonEnforcer{ > >>>>> //nothing else required here > >>>>> } > >>>>> > >>>>> > >>>>> > >>>>> -- > >>>>> View this message in context: > >>>>> > >>>> > >>> > >> > http://apache-flex-development.2333347.n4.nabble.com/FlexJS-FalconJX-Internal-Classes-tp50091p50102.html > >>>>> Sent from the Apache Flex Development mailing list archive at > >>> Nabble.com. > >>>>> > >>>> > >>> > >> > >