News Feed

News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Igor Wiedler:
Evolving syntax
July 31, 2013 @ 11:44:07

In a new post to his site Igor Wiedler looks forward and suggests some alternate syntax for PHP based around the idea of macros from Lisp. These macros would be parsed at runtime and handled directly as code, compiled down from their custom format.

A very common problem that many software projects have is lack of adoption of new versions. Browsers are an excellent example of this, But it exists on the server as well. [...] This leads to this recursive problem of hosting companies not upgrading because they don't have to, and software not requiring newer versions of their programming language, because they don't want to lose their users. The longer your dependency chain is, the more you suffer from this.

He points out that the easier it is to update these lower level pieces, the simpler it is to introduce new things into your system. He suggest that macro-like functionality for PHP could aid in this goal. He talks some about backporting features and how these marcos could make it easier to upgrade just the things we wanted (or all of them) without having to upgrade PHP itself. He even went so far as to create a tool (galapagos) that does this kind of parsing. His examples implement the 5.4 features of short arrays, $this in closures, function array dereferencing and callable typehinting.

Being able to invent your own syntax is very useful, which instantly becomes apparent when you look at the past. Features get added to languages all the time. What if you could do that easily, within minutes instead of months?
0 comments voice your opinion now!
evolve syntax lisp macro feature galapagos parse ast language

Rewriting macros - the peculiar case of php
August 17, 2006 @ 07:29:04

On today, there's a new post that's a continuation of a series (first post, second post) dealing with macro programming in PHP.

Without going into theoretical details, some of which are quite alien to me, I'll try to describe some of the challenges that pattern patching rewriting macros might pose for a language like php. After brief explanation what kind of a beast is this, I try to explore some of the finer points, which might cause problems. The intent of this post is to sketch a design and highlight some of the possible issues.

He breaks up the post into a few sections:

  • pattern matching rewrite only macros - a bird eye view
  • Transformation time
  • Basic/skeleton shapes and intermediate shapes
  • Code generation issues specific to php
  • Hygiene
  • A rough macro shape outline
  • Output/Status of the project
There are code examples (of how it should work) and explainations of the issues PHP would face to accomplish this goal.

1 comment voice your opinion now!
rewrite macro pattern match transformation skeleton generation hygiene rewrite macro pattern match transformation skeleton generation hygiene
Poor man's macro programming in php (revisited)
August 01, 2006 @ 06:16:38

In refernece to his previous post on macro programming in PHP, vlado is back with this new post answering the question "How exactly can you do macros in php now?"

Macros have (let's say) two main responsibilities - adding syntactic sugar and abstraction of common patterns. The syntactic sugar bit is something which probably should happen at compile time, at least in a weakly typed language like php. So I'll skip them. The abstraction of computation, well this is wat codified design patterns are.

He illustrates what a macro might look like, using the generic functions and partial evaluation patterns to accomplish it. He also shows it being possible with something built around a create_function call.

So what do these example prove? Well, php has decent abstraction mechanisms. The fact that we can do indirect function calls and indirect variable (symbol) resolution can give us useful means to code in different design patterns. How can we make proper macros? Is it too complicated to have something like dylan macros (a nice paper from 1999)
0 comments voice your opinion now!
macro programming design patterns revisited macro programming design patterns revisited
Poor man's macro programming in php
July 26, 2006 @ 13:27:48

vlado, thinking more about a previous post, started wondering what exactly you'd need to do to get macros working in PHP. Read on for his answers.

What is the closest we can get to that without actually changing anything in php (poor man's version? What minimal sugar does php need to make it comfy? What is the natural syntax for macros in php? I definitely don't know the answers to these questions but let's try.

He doesn't create working code, but he does make it a PHP-ish looking solution. He also suggests that while PHP doesn't have this ability (yet?), the generic function pattern can help mimic its functionality pretty closely.

0 comments voice your opinion now!
macro programming poor man generic function pattern macro programming poor man generic function pattern

Jonnay's Blog:
Googles Summer of yawn.
July 26, 2006 @ 05:38:29

On his blog today, Jonnay looks at the Google "Summer of Code" (or as he calls it, their "Summer of Yawn"), specifically at one project, the PHP Macro Preprocessor.

This (as described) sounds exactly like a rewrite of the C preprocessor, which one can work with fairly easily in a PHP environment. To see this duplication of effort on something so boring and useless makes me question just how much PHP is its own language, versus a Frankensteins monster of language clones; see PHP 5's object system for a perfect example.

He comments that maybe the developer should have come up with a different way to do it instead of making what appears to be a sibling of the current processor. He also suggests that PHP developers step up and create methods for the current compiler to make using things like design patterns much simpler than they currently are.

0 comments voice your opinion now!
summer google macro preprocessor project summer google macro preprocessor project

Community Events

Don't see your event here?
Let us know!

laravel application series example php7 part2 interview api programming community symfony list opinion yii2 introduction language podcast framework composer project

All content copyright, 2015 :: - Powered by the Solar PHP Framework