I want to request a C/C++ feature that i think is good.
MACRO
<?php
MACRO('PF','private function ');
MACRO('SCOPE_CLASS','class MyProject');
class UseMacro
{
PF preSave($object)
{
//...
}
}
SCOPE_CLASS Internal
{
}
I don know if there is a RFC for this feature.
<?php
MACRO('TE','throw new Excpeption();');
function test($var) {
if ($var < 0) {
TE
}
}
On Wed, Dec 22, 2010 at 3:11 PM, Mathias Grimm mathiasgrimm@gmail.comwrote:
I want to request a C/C++ feature that i think is good.
MACRO
<?php
MACRO('PF','private function ');
MACRO('SCOPE_CLASS','class MyProject');class UseMacro
{
PF preSave($object)
{
//...
}}
SCOPE_CLASS Internal
{}
I don know if there is a RFC for this feature.
Am 22.12.2010 18:11, schrieb Mathias Grimm:
I want to request a C/C++ feature that i think is good.
MACRO
- https://github.com/andreiz/prep (extension for the PHP interpreter)
- https://github.com/theseer/preprocessor (userland implementation)
--
Sebastian Bergmann Co-Founder and Principal Consultant
http://sebastian-bergmann.de/ http://thePHP.cc/
Hi!
I want to request a C/C++ feature that i think is good.
MACRO
You know that you could write:
<?php
#define PF private function
#define SCOPE_CLASS(x) class MyProject_ ## x
class UseMacro
{
PF preSave($object)
{
//...
}
}
SCOPE_CLASS(Internal)
{
}
And then run it through CPP (gcc -Mcpp -E - - < in.php > out.php) and
get all the macros processed?
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
I Just want a simple replace-on-the-air to avoid spend time writing more.
On Wed, Dec 22, 2010 at 5:43 PM, Stas Malyshev smalyshev@sugarcrm.comwrote:
Hi!
I want to request a C/C++ feature that i think is good.
MACRO
You know that you could write:
<?php
#define PF private function
#define SCOPE_CLASS(x) class MyProject_ ## xclass UseMacro
{
PF preSave($object)
{
//...
}}
SCOPE_CLASS(Internal)
{}
And then run it through CPP (gcc -Mcpp -E - - < in.php > out.php) and get
all the macros processed?Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
I really dislike this, what about resolving orders, then people will want undef, then ifdef with conditions.
The language doesn't need to introduce anything that makes it more complex to use.
- Scott
I Just want a simple replace-on-the-air to avoid spend time writing more.
On Wed, Dec 22, 2010 at 5:43 PM, Stas Malyshev smalyshev@sugarcrm.comwrote:
Hi!
I want to request a C/C++ feature that i think is good.
MACRO
You know that you could write:
<?php
#define PF private function
#define SCOPE_CLASS(x) class MyProject_ ## xclass UseMacro
{
PF preSave($object)
{
//...
}}
SCOPE_CLASS(Internal)
{}
And then run it through CPP (gcc -Mcpp -E - - < in.php > out.php) and get
all the macros processed?Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
People always will want more, but some features are nice.
for C/C++ programmers, macro is on of the best things to make thing work
every where.
its possible to create a IDE macro, but the native php feature will be good.
template engines can de wrap this functionality too.
is just like a variable:
$method = $_GET['m'];
$control = $_GET['c'];
$c = new $control;
$c->$method();
like a macro..
program is make thing dynamic.
while($object = $iterator->next()) {
}
macro("ITER","while($object = $iterator->next())")
ITER($iterator) {
$object->save();
}
I really dislike this, what about resolving orders, then people will want
undef, then ifdef with conditions.The language doesn't need to introduce anything that makes it more complex
to use.
- Scott
I Just want a simple replace-on-the-air to avoid spend time writing more.
On Wed, Dec 22, 2010 at 5:43 PM, Stas Malyshev <smalyshev@sugarcrm.com
wrote:Hi!
I want to request a C/C++ feature that i think is good.
MACRO
You know that you could write:
<?php
#define PF private function
#define SCOPE_CLASS(x) class MyProject_ ## xclass UseMacro
{
PF preSave($object)
{
//...
}}
SCOPE_CLASS(Internal)
{}
And then run it through CPP (gcc -Mcpp -E - - < in.php > out.php) and
get
all the macros processed?Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
People always will want more, but some features are nice.
for C/C++ programmers, macro is on of the best things to make thing work
every where.its possible to create a IDE macro, but the native php feature will be good.
template engines can de wrap this functionality too.
is just like a variable:
I've long wished for preprocessing in PHP. It would be semi-trivial to plug in libcpp from GCC or llvm's preprocessing library, if licensing weren't an issue. If it is, then a reasonable homegrown implementation of C's preprocessor semantics, or at least a subset of them, isn't that difficult.
Piping through cpp has two major problems:
- It's an extra runtime step. Slower, more error-prone, not always an option (shared hosting anyone?).
- cpp doesn't understand # comments, single-quoted strings, heredocs, etc. Many PHP scripts therefore produce annoying/confusing errors.
Some issues with PHP-native preprocessing:
- Are eval() strings subject to it? At what stage, outer script processing or the eval string?
- #include/#import versus include()/require() - confusing
- Does preprocessing take place outside whatever PHP tags are active?
I really dislike this, what about resolving orders, then people will want
undef, then ifdef with conditions.The language doesn't need to introduce anything that makes it more complex
to use.
- Scott
I Just want a simple replace-on-the-air to avoid spend time writing more.
On Wed, Dec 22, 2010 at 5:43 PM, Stas Malyshev <smalyshev@sugarcrm.com
wrote:Hi!
I want to request a C/C++ feature that i think is good.
MACRO
You know that you could write:
<?php
#define PF private function
#define SCOPE_CLASS(x) class MyProject_ ## xclass UseMacro
{
PF preSave($object)
{
//...
}}
SCOPE_CLASS(Internal)
{}
And then run it through CPP (gcc -Mcpp -E - - < in.php > out.php) and
get
all the macros processed?Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
-- Gwynne
Am 22.12.2010 20:43, schrieb Stas Malyshev:
And then run it through CPP (gcc -Mcpp -E - - < in.php > out.php) and
get all the macros processed?
That would be too easy ;-)
--
Sebastian Bergmann Co-Founder and Principal Consultant
http://sebastian-bergmann.de/ http://thePHP.cc/
-----Original Message-----
From: Mathias Grimm [mailto:mathiasgrimm@gmail.com]
Sent: Wednesday, December 22, 2010 9:12 AM
To: internals@lists.php.net
Subject: [PHP-DEV] RFC - MACROI want to request a C/C++ feature that i think is good.
MACRO
<?php
MACRO('PF','private function ');
MACRO('SCOPE_CLASS','class MyProject');class UseMacro
{
PF preSave($object)
{
//...
}}
SCOPE_CLASS Internal
{}
I don know if there is a RFC for this feature.
Although I am a C developer and use macros I think it'd be horrible to add them to PHP (+ it's been discussed and rejected many times in the past).
Macros make it very hard for a third party person to read your code + goes directly against the verbosity spirit we've always had in the PHP project. Forget also the fact that it creates a lot of problems with solutions such as debuggers.
I suggest if it's something you really feel you need then implement it externally to PHP as part of your build and deployment environment. There are a variety of templating/pre-processor solutions out there including the C-compiler tools themselves.
Andi
This has been brought up countless times and has always been rejected
(browse the archives if you aren't convinced).
Anyhow, I just hope I never have to maintain code you write in this fashion.
Pre-compilation macros are very out of character in the dynamic languages
paradigm and I doubt they'd be useful in any case. The examples you gave
convinced me once and for all that this is a very² bad idea. There's a
reason why no modern language uses three letters tokens for common
statements, I'll let you guess what it is.
Anyhow, merry Christmas.
P.S.: SCOPE_CLASS ? Have you ever heard of namespaces ?
On Wed, Dec 22, 2010 at 12:11 PM, Mathias Grimm mathiasgrimm@gmail.comwrote:
I want to request a C/C++ feature that i think is good.
MACRO
<?php
MACRO('PF','private function ');
MACRO('SCOPE_CLASS','class MyProject');class UseMacro
{
PF preSave($object)
{
//...
}}
SCOPE_CLASS Internal
{}
I don know if there is a RFC for this feature.
--
Nicolas A. Bérard-Nault (nicobn@gmail.com)
You never know me.
php 4 doesnt have namespace, it was just an example.
zend framework dont use namespecaes yet... and classe names get longer for
example.
a think that macros in the framework, not in the user (programmer) space are
usefull sometimes. as i sad before.. RET_IF_ERR is very clean and anyone can
understand it.
as well as framewrok methods need to be understand, some macros will too
2010/12/24 Nicolas A. Bérard-Nault nicobn@gmail.com
This has been brought up countless times and has always been rejected
(browse the archives if you aren't convinced).Anyhow, I just hope I never have to maintain code you write in this
fashion. Pre-compilation macros are very out of character in the dynamic
languages paradigm and I doubt they'd be useful in any case. The examples
you gave convinced me once and for all that this is a very² bad idea.
There's a reason why no modern language uses three letters tokens for common
statements, I'll let you guess what it is.Anyhow, merry Christmas.
P.S.: SCOPE_CLASS ? Have you ever heard of namespaces ?
On Wed, Dec 22, 2010 at 12:11 PM, Mathias Grimm mathiasgrimm@gmail.comwrote:
I want to request a C/C++ feature that i think is good.
MACRO
<?php
MACRO('PF','private function ');
MACRO('SCOPE_CLASS','class MyProject');class UseMacro
{
PF preSave($object)
{
//...
}}
SCOPE_CLASS Internal
{}
I don know if there is a RFC for this feature.
--
Nicolas A. Bérard-Nault (nicobn@gmail.com)
php 4 doesnt have namespace, it was just an example.
zend framework dont use namespecaes yet... and classe names get longer for
example.
But that doesn't stop you from using PHP 5.3 and using class aliasing
already (heck, I do this already, particularly in examples for
webinars/conference sessions). This accomplishes the same thing (in this
particular scope), using features already available in the language.
a think that macros in the framework, not in the user (programmer)
space are usefull sometimes.
I'd argue the opposite. Within a framework, you want the code to be as
readable as possible, so anybody can pick it up and help maintain it.
That often means a certain level of verbosity, to ensure developers know
exactly what is going on at each and every level of the code.
as i sad before.. RET_IF_ERR is very clean and anyone can understand
it.as well as framewrok methods need to be understand, some macros will
too2010/12/24 Nicolas A. B=E9rard-Nault nicobn@gmail.com
This has been brought up countless times and has always been rejected
(browse the archives if you aren't convinced).Anyhow, I just hope I never have to maintain code you write in this
fashion. Pre-compilation macros are very out of character in the dynamic
languages paradigm and I doubt they'd be useful in any case. The examples
you gave convinced me once and for all that this is a very=B2 bad idea.
There's a reason why no modern language uses three letters tokens for com=
mon
statements, I'll let you guess what it is.Anyhow, merry Christmas.
P.S.: SCOPE_CLASS ? Have you ever heard of namespaces ?
On Wed, Dec 22, 2010 at 12:11 PM, Mathias Grimm mathiasgrimm@gmail.comw=
rote:I want to request a C/C++ feature that i think is good.
MACRO
<?php
MACRO('PF','private function ');
MACRO('SCOPE_CLASS','class MyProject');class UseMacro
{
PF preSave($object)
{
//...
}}
SCOPE_CLASS Internal
{}
I don know if there is a RFC for this feature.
--
Nicolas A. B=E9rard-Nault (nicobn@gmail.com)--00235445ba821c252204983cbac0--
--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
I want to request a C/C++ feature that i think is good.
MACRO
FWIW, you could use Prep ( https://github.com/andreiz/prep ) and GPP ( http://en.nothingisreal.com/wiki/GPP ) to accomplish this.
S