Hi Guilherme

2009/6/18 Guilherme Blanco <guilhermebla...@gmail.com>:
> Hi guys,
>
>
> First of all, don't laugh! =D
>
> The idea and patch are extremely simple.
> Based on recent experiments with Namespaces and FQCN thing I spoke
> with Johannes a couple of days ago, I decided to dive into source and
> try a possible patch.
> That's my first attempt to contribution to internals. Mainly I try to
> help on PHP side.

I don't think we should introduce a new special constant for this,
seems sort of useless to me, I know theres issues with FQCN, but I'll
rather write:

$ns = '\\' . $dynamic_class_name . '\\' . $blah;

than:
$ns = NS_SEPARATOR . $dynamic_class_name . NS_SEPARATOR . $blah;

so im a -1 for introducing this in PHP, even though im using a danish
keyboard that doesn't have \, but thats not a reason not to press 2
buttons at once, that you're already used to if you code.

>
> The idea is to create a new global constant NS_SEPARATOR to be used. I
> know constants are used to represent internal values or values that
> differ between different OS's, but the main idea here is to prevent
> possible issues from user land and also to help people that do not
> have "\" key in their keyboard (like finnish keyboards).
> Here is a clear usage of this new constant:
> http://www.php.net/manual/en/language.namespaces.dynamic.php#91552
>
> I don't really know if the file is the right one to have this
> constant, but it works for me perfectly.
>
>
> Index: Zend/zend_constants.c
> ===================================================================
> RCS file: /repository/ZendEngine2/zend_constants.c,v
> retrieving revision 1.71.2.5.2.7.2.17
> diff -u -r1.71.2.5.2.7.2.17 zend_constants.c
> --- Zend/zend_constants.c       12 Jan 2009 21:54:37 -0000
> 1.71.2.5.2.7.2.17
> +++ Zend/zend_constants.c       18 Jun 2009 15:29:52 -0000
>  -151,6 +151,13 @@
>                c.value.type = IS_BOOL;
>                zend_register_constant(&c TSRMLS_CC);
>        }
> +
> +       /* Namespace separator constant */
> +       static char nssep_str[2];
> +       nssep_str[0] = '\\';
> +       nssep_str[1] = '\0';
> +
> +       REGISTER_MAIN_STRING_CONSTANT("NS_SEPARATOR", nssep_str,
> CONST_PERSISTENT | CONST_CS);
>  }

This is most likely to break the Windows build without looking at the
code any closer because of the declaring, just use:
REGISTER_MAIN_STRING_CONSTANT("NS_SEPARATOR", ZEND_NS_NAME,
CONST_PERSISTENT | CONST_CS);

(I think it was ZEND_NS_NAME for the seperator)

>
>
>
> Cheers,
>
> --
> Guilherme Blanco - Web Developer
> CBC - Certified Bindows Consultant
> Cell Phone: +55 (16) 9215-8480
> MSN: guilhermebla...@hotmail.com
> URL: http://blog.bisna.com
> São Paulo - SP/Brazil
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
regrads,

Kalle Sommer Nielsen
ka...@php.net

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

Reply via email to