Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Dec. 22, 2010 17:34:08

Sebastian B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] RFC - MACRO


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 Consultanthttp://sebastian-bergmann.de/http://thePHP.cc/--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#2 Dec. 22, 2010 19:44:11

Stas M.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] RFC - MACRO


Hi!I want to request a C/C++ feature that i think is good.

MACROYou 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) andget all the macros processed?--
Stanislav Malyshev, Software Architect
SugarCRM:http://www.sugarcrm.com/(408)454-6900 ext. 227

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#3 Dec. 22, 2010 19:56:39

Mathias G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] RFC - MACRO


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 <smalys***@*ugarcrm.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_ ## 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
>

Offline

#4 Dec. 22, 2010 21:09:38

Scott M.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] RFC - MACRO


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

On 22 Dec 2010, at 11:55, Mathias Grimm <mathiasgr***@*mail.com> wrote:

> 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 <smalys***@*ugarcrm.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_ ## 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
>>

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#5 Dec. 22, 2010 21:39:07

Mathias G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] RFC - MACRO


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;
$control = $_GET;

$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();
}


On Wed, Dec 22, 2010 at 7:08 PM, Scott MacVicar <sc***@*acvicar.net> wrote:

> 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
>
> On 22 Dec 2010, at 11:55, Mathias Grimm <mathiasgr***@*mail.com> wrote:
>
> > 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 <smalys***@*ugarcrm.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_ ## 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
> >>
>

Offline

#6 Dec. 22, 2010 21:48:11

James B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] RFC - MACRO


-----Original Message-----
> From: Mathias Grimm

> 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;
> $control = $_GET;
>
> $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();
> }


>From a userland perspective this looks very un-PHP and potentially hugely
>confusing when new people come across it. Also what scope would these things
>exist at? global scope macro's sound like evil waiting to happen
What you are doing looks to be just slightly re-inventing the wheel for very
little gain. If you are copy and pasting code 'DRY violation' then you probably
need to rethink your code and/or make a new class/function of some sort.
Unless i'm missing something?


On Wed, Dec 22, 2010 at 7:08 PM, Scott MacVicar <sc***@*acvicar.net> wrote:

> 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
>
> On 22 Dec 2010, at 11:55, Mathias Grimm <mathiasgr***@*mail.com> wrote:
>
> > 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 <smalys***@*ugarcrm.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_ ## 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
> >>
>


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#7 Dec. 22, 2010 22:15:24

Sebastian B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] RFC - MACRO


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 Consultanthttp://sebastian-bergmann.de/http://thePHP.cc/--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#8 Dec. 22, 2010 22:29:00

Gwynne R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] RFC - MACRO


On Dec 22, 2010, at 4:38 PM, Mathias Grimm wrote:
> 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:
1) It's an extra runtime step. Slower, more error-prone, not always an option
(shared hosting anyone?).
2) 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?

> On Wed, Dec 22, 2010 at 7:08 PM, Scott MacVicar <sc***@*acvicar.net> wrote:
>> 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
>>
>> On 22 Dec 2010, at 11:55, Mathias Grimm <mathiasgr***@*mail.com> wrote:
>>> 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 <smalys***@*ugarcrm.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_ ## 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
>>>>
>>

-- Gwynne


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#9 Dec. 23, 2010 00:49:28

Mathias G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] RFC - MACRO


On Wed, Dec 22, 2010 at 7:47 PM, James Butler <
james.but***@*digitalresearch.com> wrote:
"What you are doing looks to be just slightly re-inventing the wheel for
very little gain. If you are copy and pasting code 'DRY violation' then you
probably need to rethink your code and/or make a new class/function of some
sort.
Unless i'm missing something?"

There are some projects (like one that im working) have more than 3.000.000
lines of O.O php coding.
Isn't it a cut and paste, but are some code that everywhere i need to
repeat, for exemplo (php4 yet)

$obError = $object->fetch($params,$transaction);
if ($obError->hasError()) { return $obError;) // this is repeated everey
processing... every method call.. like try catch..

i could replace with a macro:
MACRO("HND_ERR","if ($obError->hasError()) { return $obError;)")
$obError = $object->fetch($params,$transaction);
HND_ERR

Offline

#10 Dec. 23, 2010 00:58:49

Gustavo L.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-DEV] RFC - MACRO


On Thu, 23 Dec 2010 00:48:44 -0000, Mathias Grimm <mathiasgr***@*mail.com>wrote:On Wed, Dec 22, 2010 at 7:47 PM, James Butler<james.but***@*digitalresearch.com> wrote:i could replace with a macro:
MACRO("HND_ERR","if ($obError->hasError()) { return $obError;)")
$obError = $object->fetch($params,$transaction);
HND_ERRSo, not only do you want macros, you want to write flow control macros...http://blogs.msdn.com/b/oldnewthing/archive/2005/01/06/347666.aspx--
Gustavo Lopes

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

Board footer

Moderator control

Enjoy the 11th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support