a proposal about "with" syntax

classic Classic list List threaded Threaded
64 messages Options
1234
Reply | Threaded
Open this post in threaded view
|

Re: a proposal about "with" syntax

Bart-48
On 3/18/13, Jürgen Hestermann <[hidden email]> wrote:

> You won't cripple down all variables to one letter names A, B, C only
> because this is easier to type, won't you?

You would if you'ld be programming in MUMPS ;-)

Bart
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: a proposal about "with" syntax

el_es
In reply to this post by Paul Ishenin
On 18/03/2013 03:11, Paul Ishenin wrote:

> 18.03.13, 9:27, Xiangrong Fang пишет:
>> I am sorry I didn't follow this thread although I am the "OP" :-).   If
>> I understand correct, I would suggest NOT introduce the "absolute"
>> keyword, instead, make it ALWAYS absolute. i.e.:
>>
>> with a = SomeObject, b = SomeRecord do begin
>>    ... ...
>> end;
>>
>> Both a and b are "reference" to the object or record, IMO there seems no
>> need to do assignment in the with syntax. Thus, I suggest use = instead
>> of :=
>
> '=' can't be used because it can be a part of expression. There is no big difference between
> with (a = SomeObject) do
> and
> with a = SomeObject do
>
> After more thinking I see that ':=' as well as absolute keyword are also bad because they will complicate the parser (although it is possible to use them). Parser will need to read the first token and check if it is an identifier, read second token and compare with ':=' (or 'absolute') and if it is not ':=' (or 'absolute') return to expression parse.
>
> At the same time we will not complicate the parser if we place alias identifier after the with expression like:
>
> with expression1, expression2 => alias2, expression3, expression4 => alias4 do
>
> begin
>
> end;
>
> Where '=>' is some token which can't be used in expressions.
>
For example '@' ?

e.g.
with alias1@SomeLongObject, alias2@SomeOtherLongObject, ... do

rationale:
it's sufficiently different, and as for its nominal usage, it does similar
thing.

?

> Best regards,
> Paul Ishenin
>

Lukasz


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: a proposal about "with" syntax

Luca Olivetti-2
In reply to this post by Paul Ishenin
Al 18/03/13 04:11, En/na Paul Ishenin ha escrit:

> '=' can't be used because it can be a part of expression. There is no
> big difference between
> with (a = SomeObject) do
> and
> with a = SomeObject do

But since "with" is only for records/objects/classes there's no possible
confusion (the result of the expression being a boolean).

Bye
--
Luca


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: a proposal about "with" syntax

shiruba2012
In reply to this post by el_es
Hi,

Actually, this sort-of makes sense.  I find "as" or something similar to be more aesthetically pleasing, but @ seems to make it clear that the identifier is just an alias (pointer address), and not a real temporary variable.  

Of course I would be happy for any keyword or syntax that actually allows this to be done.  Theoretically you could already use "absolute" instead, but...

Thank you,
    Noah Silva

2013/3/20 Lukasz Sokol <[hidden email]>
On 18/03/2013 03:11, Paul Ishenin wrote:
> 18.03.13, 9:27, Xiangrong Fang пишет:
>> I am sorry I didn't follow this thread although I am the "OP" :-).   If
>> I understand correct, I would suggest NOT introduce the "absolute"
>> keyword, instead, make it ALWAYS absolute. i.e.:
>>
>> with a = SomeObject, b = SomeRecord do begin
>>    ... ...
>> end;
>>
>> Both a and b are "reference" to the object or record, IMO there seems no
>> need to do assignment in the with syntax. Thus, I suggest use = instead
>> of :=
>
> '=' can't be used because it can be a part of expression. There is no big difference between
> with (a = SomeObject) do
> and
> with a = SomeObject do
>
> After more thinking I see that ':=' as well as absolute keyword are also bad because they will complicate the parser (although it is possible to use them). Parser will need to read the first token and check if it is an identifier, read second token and compare with ':=' (or 'absolute') and if it is not ':=' (or 'absolute') return to expression parse.
>
> At the same time we will not complicate the parser if we place alias identifier after the with expression like:
>
> with expression1, expression2 => alias2, expression3, expression4 => alias4 do
>
> begin
>
> end;
>
> Where '=>' is some token which can't be used in expressions.
>
For example '@' ?

e.g.
with alias1@SomeLongObject, alias2@SomeOtherLongObject, ... do

rationale:
it's sufficiently different, and as for its nominal usage, it does similar
thing.

?

> Best regards,
> Paul Ishenin
>

Lukasz


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
1234