Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-30 Thread Hamza Ahmad
Being positive is good but relying on others is not. If you really
believe that your idea is worth considering, I suggest revisiting it.
You can ask your self the following questions:
  - How is it useful?
  - what special thing does it provide with that the current
implementation does not?
  - What could be the better syntax?
  - Does any other language have the similar feature?
  - If yes, what is the benefit?
  - Will your idea cause any BC break?
  - Do your proposed syntax make any confusion?
  - How can you make it further clear?

If you have answers to all of these questions, you can come and
convince the people here. Still, I don't find your proposal till now
that compelling.

Rather considering the opinions shared here as an offence, take them
positively and redesign your thought.

Best

Hamza

On 6/30/21, Manuel Canga  wrote:
>
>   En mié, 30 jun 2021 14:29:40 +0200 G. P. B. 
> escribió 
>  > Ignoring the fact that this proposal is way past the cutoff date to be
> able to make it into PHP 8.1 due to how the RFC process works,it seems that
> this feature just came into your mind and you decided to send it onto the
> list without considering its ramifications.Userland contribution and
> opinions on new features (or other internal discussion) is valuable but
> oughts to consider all the ramifications, good and bad, and how it affects
> the language as a whole. I say this because I didn't do this when I started
> contributing on this list and it made for less than stellar discussions.
>
> Hi, George,
>
> I am not an expert in developing programming languages. However, I don't
> agree with that.
>
> When Dennis Ritchie and Brian Kernighan developed C. They didn't think in
> avoid pointers because of they thought what they could be dangerous.
> Surely when someone invented air planes, he didn't think of risks but
> opportunities
>
> It was my fault. I thought that someone here would propose an idea and if
> this was useful, then everyone would find the best way to put it into code.
>
> With last Rowan email, I understood that this purpose is useless. However,
> if it had been useful, I had expected answers like:
> "hey, Manuel, ``` is dangerous, why don't use other syntax like ...  ?
> or
> "Manuel,  why don't use this for heredoc ?
>
> In one word: Synergy.
>
> Why should this be done?. Because someone can read my purpose and can modify
> to something better, maybe a great change to the language.
>
> I think so.
>
> Regards,
> Manuel Canga
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>
>

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



Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-30 Thread Manuel Canga


  En mié, 30 jun 2021 14:29:40 +0200 G. P. B.  
escribió 
 > Ignoring the fact that this proposal is way past the cutoff date to be able 
 > to make it into PHP 8.1 due to how the RFC process works,it seems that this 
 > feature just came into your mind and you decided to send it onto the list 
 > without considering its ramifications.Userland contribution and opinions on 
 > new features (or other internal discussion) is valuable but oughts to 
 > consider all the ramifications, good and bad, and how it affects the 
 > language as a whole. I say this because I didn't do this when I started 
 > contributing on this list and it made for less than stellar discussions.

Hi, George,

I am not an expert in developing programming languages. However, I don't agree 
with that.

When Dennis Ritchie and Brian Kernighan developed C. They didn't think in avoid 
pointers because of they thought what they could be dangerous.
Surely when someone invented air planes, he didn't think of risks but 
opportunities

It was my fault. I thought that someone here would propose an idea and if this 
was useful, then everyone would find the best way to put it into code.

With last Rowan email, I understood that this purpose is useless. However, if 
it had been useful, I had expected answers like:
"hey, Manuel, ``` is dangerous, why don't use other syntax like ...  ?
or
"Manuel,  why don't use this for heredoc ?

In one word: Synergy.

Why should this be done?. Because someone can read my purpose and can modify to 
something better, maybe a great change to the language.

I think so. 

Regards, 
Manuel Canga

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



Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-30 Thread G. P. B.
On Tue, 29 Jun 2021 at 18:15, Manuel Canga  wrote:

> Hi, folks, here again with a new purpose:  ``` as alternative to Nowdoc
> syntax.
>
> Currently, Nowdoc syntax is very "verbose":
>
> $string =<<<'CODE'
> 
> Link: '%s'
> 
> CODE;
>
> Why doesn't something like this?:
>
> $string =```
> 
> Link: '%s'
> 
> ```;
>
> even as well:
>
> $string =```Link: '%s'```;
>
>
> I see a caveat: this is very similar to `eval` syntax. However, this
> syntax is more similar to Markdown syntax.
>
> What do you think ?
>
> Regards
> Manuel Canga
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>
>
I'm going to be harsh, but this proposal is utterly useless and harmful.
As already stated by other people this is just the same as single quotes,
and we frankly don't need yet another way of writing strings.
This doesn't even try to solve the issue with string interpolation that JS
does with backticks, which is an area in PHP which is quite a mess.

Now onto why this proposal is harmful:
This reuses syntax which has *very* different semantics (i.e. shell
execution) for something different,
moreso that the shell execution operator in PHP is valid markdown to go
into the same literal parsing mode as what the triple backtick do, just
inline.
Even if we deprecated the shell operator (RFC which got shutdown already) I
don't think it would be reasonable to reintroduce it without one full major
release cycle where it didn't have any effect/is a parse error.
This is also harmful for MarkDown because the whole point of the triple
backtick which kicks you into a literal parsing mode,
is so that you do not need to escape anything within this block, so your
suggestion to "just escape" goes against the very point of this syntax in
MarkDown,
which was probably chosen because it did not conflict with any programming
language whatsoever making it safe for this usage.

Ignoring the fact that this proposal is way past the cutoff date to be able
to make it into PHP 8.1 due to how the RFC process works,
it seems that this feature just came into your mind and you decided to send
it onto the list without considering its ramifications.
Userland contribution and opinions on new features (or other internal
discussion) is valuable but oughts to consider all the ramifications, good
and bad, and how it affects the language as a whole.
I say this because I didn't do this when I started contributing on this
list and it made for less than stellar discussions.
I would also recommend to any reader of this list who wants to propose a
new feature to do this at the start of a new release around September,
compared to moments before feature freeze where there are already a lot of
proposals flying around from many old-time core contributors.
The other benefit of doing this earlier than later is that you might even
be able to get someone to hand hold you to create a patch for the feature.

All this to say, this is a massive -1 from my end on this proposal.

Best regards,

George P. Banyard


Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-30 Thread Rowan Tommins

On 30/06/2021 11:51, Manuel Canga wrote:

I see this purpose as a simplification of Nowdocs. Just like `[]` with 
`array()`.



A PHP code base might have thousands of array literals, some of which 
will be very short, and maybe nested inside each other. That makes the 
saving of 5 characters per literal add up to a big difference across the 
code base.


On the other hand, nowdocs will generally be for long strings 
(otherwise, a single- or double-quoted string would be more concise 
anyway), and will happen a handful of times across the code base. Saving 
5 characters per nowdoc (``` instead of <<<'EOF') is therefore a much 
more minor difference.


In exchange for that small gain, we'd be adding an extra rule in every 
PHP parser (IDEs, code style tools, etc), and an extra thing for new 
developers to understand (the documentation for how to write strings is 
already long enough to get bored halfway through).


I think there is more cost than benefit.

Regards,

--
Rowan Tommins
[IMSoP]

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



Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-30 Thread Hamza Ahmad
Hi Manuel,

If I am not wrong, is not your proposal similar to python's
triple-quoted? It is confusing; don't do this. Instead, current syntax
are sufficient. Second, (`) have special meaning in PHP. It is used to
execute commands on a machine. Why do we have confusing syntax?

Best

Hamza Ahmad


On 6/30/21, Manuel Canga  wrote:
>   En mié, 30 jun 2021 11:03:32 +0200 Guilliam Xavier
>  escribió 
>  > Hi,
>
> Hi Guilliam
>
>  > Maybe other syntax could be used, but I don't know which. In javascript
>  > > only a backtick is used:
>  > > https://developers.google.com/web/updates/2015/01/ES6-Template-Strings
> .
>  > > But in PHP this is used as eval.
>  > >
>  >
>  > Just a precision, because you keep referring to it as "eval", which
> makes
>  > me "tick" (haha): `$cmd` (i.e. $cmd wrapped in a pair of backticks) is
> the
>  > same as shell_exec($cmd), not eval($cmd).
>
> Yes, you're right.
>
>  > (BTW, one of JS "template strings" main selling points is string
>  > substitution / variable interpolation, which is explicitly *not* wanted
>  > with nowdoc [VS heredoc].)
>
> Yes, I mean that in JS is used some similar (although as you say with
> variables).
> I would prefer to use this "feature" with nowdoc. Normally, strings with
> variables are moved to views, while large literals (like queries) are added
> inline.
>
>  > As for the proposal, overall I agree with Rowan -- well, that would not
> be
>  > exactly like single quotes (regarding [not] escaping them), but still
> "yet
>  > another way" to write a nowdoc string literal.
>
> I see this purpose as a simplification of Nowdocs. Just like `[]` with
> `array()`.
>
>  > PS: "amusingly", the code samples are hard to understand after rendered
> on
>  > https://externals.io/message/115213
>
> ups!, I'm sorry...but, look at:
> https://externals.io/message/115213#115222
> Markdown is not broken here due to ``` of code.
>
> Regards,
> Manuel Canga
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>
>

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



Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-30 Thread Manuel Canga



  En mié, 30 jun 2021 11:16:24 +0200 Lynn  escribió 
 > 
 > I'd expect a lot of markdown issues when trying to write examples using
 > backticks. While such a thing might not be blocking for a nice language
 > feature, it will surely impact the tooling in the ecosystem for
 > documentation. I already run into issues with single line code examples in
 > Discord because it gets messy real fast. Sure it's just an annoyance, but I
 > would like to suggest avoiding it if we can.
 > ```
 > `const something = `foo`;`
 > ```

Hi, Lynn. 

My intention wasn't a closed purpose. Maybe ``` is not a good syntax, In this 
case, other can be found.


Regards
Manuel Canga

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



Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-30 Thread Manuel Canga
  En mié, 30 jun 2021 11:03:32 +0200 Guilliam Xavier 
 escribió 
 > Hi,

Hi Guilliam

 > Maybe other syntax could be used, but I don't know which. In javascript
 > > only a backtick is used:
 > > https://developers.google.com/web/updates/2015/01/ES6-Template-Strings .
 > > But in PHP this is used as eval.
 > >
 > 
 > Just a precision, because you keep referring to it as "eval", which makes
 > me "tick" (haha): `$cmd` (i.e. $cmd wrapped in a pair of backticks) is the
 > same as shell_exec($cmd), not eval($cmd).

Yes, you're right. 
  
 > (BTW, one of JS "template strings" main selling points is string
 > substitution / variable interpolation, which is explicitly *not* wanted
 > with nowdoc [VS heredoc].)

Yes, I mean that in JS is used some similar (although as you say with 
variables).
I would prefer to use this "feature" with nowdoc. Normally, strings with 
variables are moved to views, while large literals (like queries) are added 
inline.
 
 > As for the proposal, overall I agree with Rowan -- well, that would not be
 > exactly like single quotes (regarding [not] escaping them), but still "yet
 > another way" to write a nowdoc string literal.

I see this purpose as a simplification of Nowdocs. Just like `[]` with 
`array()`.
  
 > PS: "amusingly", the code samples are hard to understand after rendered on
 > https://externals.io/message/115213

ups!, I'm sorry...but, look at:
https://externals.io/message/115213#115222
Markdown is not broken here due to ``` of code.

Regards,
Manuel Canga

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



Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-30 Thread Lynn
On Wed, Jun 30, 2021 at 11:03 AM Guilliam Xavier 
wrote:

> PS: "amusingly", the code samples are hard to understand after rendered on
> https://externals.io/message/115213


I'd expect a lot of markdown issues when trying to write examples using
backticks. While such a thing might not be blocking for a nice language
feature, it will surely impact the tooling in the ecosystem for
documentation. I already run into issues with single line code examples in
Discord because it gets messy real fast. Sure it's just an annoyance, but I
would like to suggest avoiding it if we can.
```
`const something = `foo`;`
```


Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-30 Thread Guilliam Xavier
Hi,

Maybe other syntax could be used, but I don't know which. In javascript
> only a backtick is used:
> https://developers.google.com/web/updates/2015/01/ES6-Template-Strings .
> But in PHP this is used as eval.
>

Just a precision, because you keep referring to it as "eval", which makes
me "tick" (haha): `$cmd` (i.e. $cmd wrapped in a pair of backticks) is the
same as shell_exec($cmd), not eval($cmd).

(BTW, one of JS "template strings" main selling points is string
substitution / variable interpolation, which is explicitly *not* wanted
with nowdoc [VS heredoc].)

As for the proposal, overall I agree with Rowan -- well, that would not be
exactly like single quotes (regarding [not] escaping them), but still "yet
another way" to write a nowdoc string literal.

PS: "amusingly", the code samples are hard to understand after rendered on
https://externals.io/message/115213

-- 
Guilliam Xavier


Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-29 Thread Manuel Canga
  En mar, 29 jun 2021 21:33:19 +0200 Michał Marcin Brzuchalski 
 escribió 
 > Hi Manuel,
 > I think a Markdown document including PHP code snippet with above examples
 > could cause issues while parsing.
 > I can imagine parsers don't expect end-of-snippet tag "```" being not an
 > end tag actually.
 > 
 > Cheers,
 > Michał Marcin Brzuchalski
 

Hi, Michal,

You can escape backticks using a different number of backticks as a wrapper. 
Examples:

1.

``There is a literal backtick (`) here.``

We're using two backstick as wrapper of one backtick.

2. Using Rowan example:


php
$markdown=```
PHP has lots of ways to write strings:  
```
$example = 'hello';  
$example = "hello";  
$example = <

Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-29 Thread Michał Marcin Brzuchalski
Hi Manuel,

wt., 29 cze 2021 o 18:16 Manuel Canga  napisał(a):

> Hi, folks, here again with a new purpose:  ``` as alternative to Nowdoc
> syntax.
>
> Currently, Nowdoc syntax is very "verbose":
>
> $string =<<<'CODE'
> 
> Link: '%s'
> 
> CODE;
>
> Why doesn't something like this?:
>
> $string =```
> 
> Link: '%s'
> 
> ```;
>
> even as well:
>
> $string =```Link: '%s'```;
>
>
> I see a caveat: this is very similar to `eval` syntax. However, this
> syntax is more similar to Markdown syntax.
>
> What do you think ?
>

I think a Markdown document including PHP code snippet with above examples
could cause issues while parsing.
I can imagine parsers don't expect end-of-snippet tag "```" being not an
end tag actually.

Cheers,
Michał Marcin Brzuchalski


Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-29 Thread Manuel Canga
  En mar, 29 jun 2021 18:40:05 +0200 Rowan Tommins 
 escribió 
 > 
 > The big advantage of heredoc and nowdoc syntax is that you can choose 
 > the delimiter to be something that you know won't occur in the string. 
 > For instance:
 > 
 > $markdown = <<<'MD'
 > PHP has lots of ways to write strings:
 > ```
 > $example = 'hello';
 > $example = "hello";
 > $example = << hello
 > EXAMPLE;
 > $example = << hello
 > EXAMPLE;
 > ```
 > MD;
 > 
 > 
 > Unless I'm missing something, your proposed syntax would just be a *more 
 > verbose* way of writing single quotes.
 
Hi, Rowan,

Basically, you're right. This would be a Heredoc variant of writing text 
without worrying about quotes (singles or doubles). Something like:

$quote =```"Sometimes it's better to leave something alone, to pause, and 
that's very true of programming." - Joyce Wheeler```;


Regards
Manuel Canga

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



Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-29 Thread Rowan Tommins

On 29/06/2021 17:15, Manuel Canga wrote:

Hi, folks, here again with a new purpose:  ``` as alternative to Nowdoc syntax.

Currently, Nowdoc syntax is very "verbose":

$string =<<<'CODE'

Link: '%s'

CODE;



The big advantage of heredoc and nowdoc syntax is that you can choose 
the delimiter to be something that you know won't occur in the string. 
For instance:


$markdown = <<<'MD'
PHP has lots of ways to write strings:
```
$example = 'hello';
$example = "hello";
$example = <

[PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-29 Thread Manuel Canga
Hi, folks, here again with a new purpose:  ``` as alternative to Nowdoc syntax.

Currently, Nowdoc syntax is very "verbose":

$string =<<<'CODE'

Link: '%s'

CODE;

Why doesn't something like this?:

$string =```

Link: '%s'

```;

even as well:

$string =```Link: '%s'```;


I see a caveat: this is very similar to `eval` syntax. However, this syntax is 
more similar to Markdown syntax. 

What do you think ?

Regards
Manuel Canga

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