# [RFC][DISCUSSION] Language Constructs Syntax Changes

- Thread: https://externals.io/message/110844
- Original archive: https://news-web.php.net/php.internals/110844
- Started by michal.brzuchalski@gmail.com on 2020-07-05T07:35:24+00:00
- Messages: 6
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #110844 — michal.brzuchalski@gmail.com — 2020-07-05T07:35:24+00:00

URL: https://externals.io/message/110844#110844

Hi internals,

I realise we're tight to the deadline but from my calculations,
this RFC should fit with 2w discussion and 2w voting before feature freeze.

The proposal is to allow two statements to skip parentheses so they don't
look like expressions.
This goes to `declare` and `__halt_compiler`.
Changes have already been implemented and respective PR's are linked to the
RFC.

You can find the RFC at
https://wiki.php.net/rfc/language-constructs-syntax-changes

There is no BC break!
Proposed changes only allow certain constructs to be considered valid.

Cheers,
Michał Marcin Brzuchalski

---

## #110971 — Nikita Popov — 2020-07-13T10:41:07+00:00

URL: https://externals.io/message/110844#110971 · In reply to: #110844

On Sun, Jul 5, 2020 at 9:36 AM Michał Marcin Brzuchalski <
michal.brzuchalski@gmail.com> wrote:

> Hi internals,
>
> I realise we're tight to the deadline but from my calculations,
> this RFC should fit with 2w discussion and 2w voting before feature freeze.
>
> The proposal is to allow two statements to skip parentheses so they don't
> look like expressions.
> This goes to `declare` and `__halt_compiler`.
> Changes have already been implemented and respective PR's are linked to the
> RFC.
>
> You can find the RFC at
> https://wiki.php.net/rfc/language-constructs-syntax-changes
>
> There is no BC break!
> Proposed changes only allow certain constructs to be considered valid.
>

I don't think introducing alternative syntax for declare and halt_compiler
is a good idea. It introduces two ways to write the same thing, without
much benefit I can see.

Your stated goal is to make it clearer that these aren't functions, but
language constructs. I'm not sure your change helps that much: While
"__halt_compiler()" looks like a function call, "__halt_compiler" looks
like a constant lookup. For the declare syntax, "declare(a = 1)" is already
illegal syntax for functions, even with the parentheses.

Regards,
Nikita

---

## #110972 — michal.brzuchalski@gmail.com — 2020-07-13T11:08:16+00:00

URL: https://externals.io/message/110844#110972 · In reply to: #110971

Hi Nikita,

pon., 13 lip 2020 o 12:41 Nikita Popov <nikita.ppv@gmail.com> napisał(a):

> On Sun, Jul 5, 2020 at 9:36 AM Michał Marcin Brzuchalski <
> michal.brzuchalski@gmail.com> wrote:
>
> > […]
>
> I don't think introducing alternative syntax for declare and halt_compiler
> is a good idea. It introduces two ways to write the same thing, without
> much benefit I can see.
>
> Your stated goal is to make it clearer that these aren't functions, but
> language constructs. I'm not sure your change helps that much: While
> "__halt_compiler()" looks like a function call, "__halt_compiler" looks
> like a constant lookup. For the declare syntax, "declare(a = 1)" is already
> illegal syntax for functions, even with the parentheses.
>

I can agree with "__halt_compiler;" similar to constant lookup, which
indeed does not mate it more clear.

Regarding the second syntax for "declare" what I wanted to achieve is
reduce the number of different syntaxes and we do have quite a few in PHP.
I've noticed that the "declare" syntax is quite similar to the const
declare if you simply remove parentheses,
which therefore IMO increases readability, consider this example:

declare strict_types = 1;
const GEAR_LIMIT = 5;

From parser perspective, these both use const_list and only differ by a
first keyword and looks similar and present the same syntax construct.
Which currently is not true and they're both presented as a different
syntax.

By introducing an alternative syntax I planned to deprecate the old as soon
as we could potentially do that.
I believe it'd be hard until we have ticks directive.

Cheers,
--
Michał Marcin Brzuchalski

---

## #110973 — Benas IML — 2020-07-13T11:33:41+00:00

URL: https://externals.io/message/110844#110973 · In reply to: #110972

Hey Michał,

Personally, I think instead of making `declare(strict_types=1);` to look
more like a constant, we should make it look more like a function.

Since it seems that the named parameters RFC is going to be accepted, I
think allowing for alternative `declare(strict_types: 1);` syntax would
make much more sense.

Best regards,
Benas


On Mon, Jul 13, 2020, 2:08 PM Michał Marcin Brzuchalski <
michal.brzuchalski@gmail.com> wrote:

> Hi Nikita,
>
> pon., 13 lip 2020 o 12:41 Nikita Popov <nikita.ppv@gmail.com> napisał(a):
>
> > […]
> don't
> > […]
> halt_compiler
> > […]
> already
> > […]
>
> I can agree with "__halt_compiler;" similar to constant lookup, which
> indeed does not mate it more clear.
>
> Regarding the second syntax for "declare" what I wanted to achieve is
> reduce the number of different syntaxes and we do have quite a few in PHP.
> I've noticed that the "declare" syntax is quite similar to the const
> declare if you simply remove parentheses,
> which therefore IMO increases readability, consider this example:
>
> declare strict_types = 1;
> const GEAR_LIMIT = 5;
>
> From parser perspective, these both use const_list and only differ by a
> first keyword and looks similar and present the same syntax construct.
> Which currently is not true and they're both presented as a different
> syntax.
>
> By introducing an alternative syntax I planned to deprecate the old as soon
> as we could potentially do that.
> I believe it'd be hard until we have ticks directive.
>
> Cheers,
> --
> Michał Marcin Brzuchalski

---

## #110983 — Dik Takken — 2020-07-13T19:45:46+00:00

URL: https://externals.io/message/110844#110983 · In reply to: #110844

> The proposal is to allow two statements to skip parentheses so they don't
> look like expressions.

I like small improvements like this one. They may not look like much but
they do add up to arrive at a cleaner language in the long run.

However, I do think the RFC should also propose to deprecate the current
syntax. Having two competing types of syntax is probably worse than
having one slightly odd syntax.

Regards,
Dik

---

## #111099 — michal.brzuchalski@gmail.com — 2020-07-22T08:35:56+00:00

URL: https://externals.io/message/110844#111099 · In reply to: #110844

Hello,

I'm withdrawing the RFC since there is not much interest in it.

Cheers,
Michał

niedz., 5 lip 2020 o 09:35 Michał Marcin Brzuchalski <
michal.brzuchalski@gmail.com> napisał(a):

> Hi internals,
>
> I realise we're tight to the deadline but from my calculations,
> this RFC should fit with 2w discussion and 2w voting before feature freeze.
>
> The proposal is to allow two statements to skip parentheses so they don't
> look like expressions.
> This goes to `declare` and `__halt_compiler`.
> Changes have already been implemented and respective PR's are linked to
> the RFC.
>
> You can find the RFC at
> https://wiki.php.net/rfc/language-constructs-syntax-changes
>
> There is no BC break!
> Proposed changes only allow certain constructs to be considered valid.
>
> Cheers,
> Michał Marcin Brzuchalski
