views:

51

answers:

1

Present day usable solution:

Note that if you use an ide or an advanced editor, you could make a code template, or record a macro that inserts '->' when you press Ctrl and '.' or something.

Netbeans has macros, and I have recorded a macro for this, and I like it a lot :) (just click the red circle toolbar button (start record macro),then type -> into the editor (thats all the macro will do, insert the arrow into the editor), then click the gray square (stop record macro) and assign the 'Ctrl dot' shortcut to it, or whatever shortcut you like)

The php plugin:

The php plugin, would also have to have a different string concatenation operator than the dot. Maybe a double dot ? Yea... why not.

All it has to do is set an activation tag so that it doesnt replace / interpreter '.' as '->' for old scripts and scripts that dont intent do use this.

Something like this: <php+ $obj.i = 5 ?> (notice the modified '<?php' tag to '<?php+' )

This way it wouldnt break old code. (and you can just add the '<?php+' code template to your editor and then type 'php tab' (for netbeans) and it would insert '<?php+' )

With the alternative syntax method you could even have old and new syntax cohabitating on the same page like this (I am illustrating this to show the great compatibility of this method, not because you would want to do this):

<?php+ $obj.i = 5; ?>

<?php $obj->str = 'a' . 'b'; ?>

You could change the tag to something more explanatory, in case somebody who doesnt know about the plugin reads the script and thinks its a syntax error

<?php-dot.com $obj.i = 5; ?>

This is easy because most editors have code templates, so its easy to assign a shortcut to it. And whoever doesnt want the dot replacement, doesnt have to use it.

These are NOT ultimate solutions, they are ONLY examples to show that solutions exist, and that arguments against replacing '->' with '.' are only excuses. (Just admit you like the arrow, its ok : )

With this potential method, nobody who doesnt want to use it would have to use it, and it wouldnt break old code. And if other problems (ahem... excuses) arise, they could be fixed too.

So who can, and who will do such a thing ?

+1  A: 

so, you're using php but dislike its syntax? You basically have three choices

stereofrog