Re: for the sake of conversation - syntax

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

 



On 29 Sep 2008, at 12:47, Nathan Rixham wrote:
Last week I got to thinking about PHP vs other languages.. sparing the details this is what I decided I'd like my code to look like :) [what *I* /as an OO developer/ need(?want)]

<?php

package com.mydom.thispackage

Looks a lot like Java, not that that's a bad thing.

{

Completely agree that multiple namespaces per file should be allowed, and using curly brackets is the obvious syntax.

 import com.anotherdom.MysqlDbHandler as DbHandlerA;
 import com.somedom.DbHandler as DbHandlerB; # "as" makes this easier
 import com.mydom.thatpackage.RssParser; # we don't have to "as"

Would this then be available as RssParser:: or would you need to specify the full name.

 import net.php.pecl.Tidy into TidySpace; # "into namespace"
 import org.nicedom.alwaysusethese.*; # why not?

How does PHP work out where these "packages" are?

 public class MyClass # visibility on classes
 {
   private $dba:DbHandlerA = new DbHandlerA();
   private $dbb:DbHandlerB = new DbHandlerB();

Can't do this. This would require the compilation phase to execute code. This is what constructors were made for.

Personally I'd prefer the fairly standard "type varname" order rather than the "varname:type" you have here.

   protected $xmlString:String;

   public function __construct( String $xml ):void #return types

Here you've switched to the "type varname" order for the parameters and gone back to ":type" for the return value. Why not just "function x(type varname) type" ?

   {
     if( TidySpace::tidy_is_xml( $xml ) ) { #namespace function call
       $this->xmlString = TidySpace::tidy_repair_string( $xml );

One would hope that when namespaces are ubiquitous there will be no need to prefix functions with package identifiers.

     }
   }

 }

}
?>

all purely a made up example; I'd be interested to here any comments or what your ideal language (/modified php) would look like.

I've never really thought about how I'd like a languages syntax to be, I've just accepted the way it is. Having said that I've built a couple of compilers in my time and for the most part they were a combination of C, C++ and Perl, much like PHP. So in that respect PHP is the one that clearly makes the most sense to me for procedural languages.

In terms of OO I've always liked the Objective-C way of doing things. It seems more natural than the C++ syntax.

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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