Re: [RFC] Constant Scalar Expressions

From: Date: Fri, 16 Aug 2013 00:00:43 +0000
Subject: Re: [RFC] Constant Scalar Expressions
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-68543@lists.php.net to get a copy of this message
if(true) return; > class Foo { > const halfpie = M_PI/2; > } > > Oooh, excellent point. Wave a finger and tell the user not to do that? I wasn't going to bring this up, but an intersectional idea I had a few years ago.... Static Constructor. Just like an instance constructor, but called on initial load. class Foo { public static __static_construct(/* no args allowed */) { /* Run on class load, similar to (main), but without better determinance */ } } * Reduces the footprint wherein a class's definition *can* change. * Solves the early exit problem * If exposed to userspace, could provide a nice encapsulation for things like stream_wrapper_register() calls.

« previous php.internals (#68543) next »