Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

I, for one, never understood why there was no "default" keyword available, but the python example is great as well.

About the rest of the article :

- the modified empty() is nice, while I still think this function accepts to much thing as empty, or at least should be more flexible.

Getter/setter : finally. Now I don't get why there is no readonly keyword which would put the variable as readonly only for the class' outer world.



The article clearly states that there are more features like a read-only keyword.

https://wiki.php.net/rfc/propertygetsetsyntax-as-implemented


That's not what he's referring to. He's specifically referring to a read-only that only affects external classes. So, the object itself could write to that field, but nothing else could.


You can set the visibility of both the properties and the getters/setters.

    class Foo {
        private $fuzz;
        
        protected $Bar {
            get { return $this->fuzz; }
            private set { $this->fuzz = $value; }
        }
    }


Yes. I understand that.

My point was just that he specifically wanted a read-only.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: