Re: PHP global namespace clogged up

From: Tim Tyler (seemysig_at_cyberspace.org)
Date: 09/06/04


Date: Mon, 06 Sep 2004 08:42:37 +0100

Terence wrote:
> Tim Tyler wrote:

>> I think:
>>
>> $a = "98.6";
>> $b = $a->floor();
>>
>> ...should fail with an "unknown method" error - and would suggest using:
>>
>> $a = "98.6";
>> $b = $a->number()->floor();
>
> or perhaps
>
> $a = "98.6";
> $b = real::parse($a); // $b is a real
> $b = (int)$b->floor(); // now $b is an int

If you want an integer - rather than a number - that doesn't look
unreasonable - but it seems further modified from the original code.

> this still requires some flexibility of typing but it's hard to know
> where to draw the line.
>
> either way, you will now *REQUIRE* ALL PHP programmers to use an OO
> notation. Unless they understand even the most basic principles of OO,
> the syntax will look confusing. I personally didn't bother to check out
> the OO side of PHP for many months after I first started learning it. It
> was a few years before I took advantage of it in any serious way.
> Requiring people to understand OO concepts straight of the bat is not
> going to help it's ease of adoption for people who aren't already
> programmers before they get into the language. Remember, PHP's shining
> success is based on it's easy accessibility. While your suggested
> notation may strenghten one of PHP's weaknesses, I believe introducing a
> compulsory OO notation will undermine it's fundamental strength of easy
> adoption.

$a -> method() is really not any harder than method($a) to learn.

I can see an issue if you have to learn two ways of doing things
(rather than one) - but that would not be needed.

Beginners would be helped by by not having two learning curves
to climb - one for the procedural syntax and one for the OO syntax.

There are also things such as getting a drop-down auto-complete
list of functions when they type $a -> in their IDE - in the
case where the type of the variable can be determined analytically
before runtime.

-- 
__________
  |im |yler  http://timtyler.org/  tim@tt1lock.org  Remove lock to reply.


Relevant Pages

  • Re: Program compression
    ... means using tools (such as parse-tree rewrite rules or syntax ... enough keyword and/or syntax to trigger expansion back to the full ... let's say you have a text string which contains the notation ... favorite notation for nested lists is, ...
    (comp.programming)
  • Re: PHP global namespace clogged up
    ... >> the OO side of PHP for many months after I first started learning it. ... >> notation may strenghten one of PHP's weaknesses, ... > to climb - one for the procedural syntax and one for the OO syntax. ...
    (comp.lang.php)
  • Re: First class types and their representation
    ... It makes sense to use a common representation ... now, the notation is a little hairy, but it is possible to map much of a C ... however "i" is regarded as a single element terminating after the the ... types, but thus far this has not been needed (if I were to add a syntax, I ...
    (comp.lang.misc)
  • Re: modifying array access syntax
    ... What I had in mind is something that resembles standard notation for the field in question, ... Recall that for beginners in mathematics, the notations typically used in mathematics are by far not obvious. ... So I think the basic tradeoff is as follows: If your interest is to develop the code for your own experiments, it's probably more effective to invest some time into learning the Lisp syntax in order to forget about syntactic issues altogether in the long run. ...
    (comp.lang.lisp)
  • Re: About those parenthesis....
    ... > So a better notation than fis quite simply f. ... > I have programmed with Lisp-like semantics using the fsyntax. ... > Even when the first symbol /is/ an operator, ... that this is not a valid reason for making it look like one of the ...
    (comp.lang.lisp)