Re: Class constants

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Apr 19, 2010 at 10:25 AM, Peter Lind <peter.e.lind@xxxxxxxxx> wrote:

> On 19 April 2010 16:18, Gary . <php-general@xxxxxxxxxxxxxxx> wrote:
> > On Mon, Apr 19, 2010 at 2:37 PM, Peter Lind <peter.e.lind@xxxxxxxxx>
> wrote:
> >> On 19 April 2010 14:24, Gary wrote:
> >>> On Mon, Apr 19, 2010 at 10:36 AM, Peter Lind wrote:
> >
> >>>> So no, you shouldn't be able to do that.
> >>>
> >>> Okay. Why not?
> >>
> >> Hate to ask, but did you at any point consider to read the PHP docs on
> >> this? The bit I sent or what you could gather from the link posted?
> >
> > Yes. The question remains.
> >
>
> Per the PHP manual: "The value must be a constant expression". Is
> something that depends on other classes, variables or functions
> constant?
>  If you're asking why a constant should be constant, I can only point
> you to Ashleys answer or google.
>
> Regards
> Peter
>
> --
> <hype>
> WWW: http://plphp.dk / http://plind.dk
> LinkedIn: http://www.linkedin.com/in/plind
> Flickr: http://www.flickr.com/photos/fake51
> BeWelcome: Fake51
> Couchsurfing: Fake51
> </hype>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Hi Gary,

Sorry for the confusion.  I understand your question.  For the life of those
variables, they would never change  If you come from other programming
language backgrounds, this can be a bit confusing.  In Objective C, the term
"constant expression" is one in which every element is a constant, so given
the requirement that "The value must be a constant expression", your
examples would make sense.  Additionally, in languages like Scala, values
default to a constant, and you can compose them in a myriad of ways.

I don't claim to know the rationale, but once you get used to it, it's not a
big deal.  I just tend to use classes that allow a value to be set once and
only once for these types of situations.

Happy coding ;)

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux