about expressions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

about expressions

Stephane Ducasse-3
I do not get why (Yes I know it is because it is not in the syntax....
but it is conceptually not nice).

| d |
d := Dictionary new.
d at: #top at: #below1 put: 1.
d at: #top at: #below1 put: 2.
d at: #top at: #below1.

is not an expression in Pharo.

It means that I can manipulate

1 + 3,
x + 3 as an expression
but not a sequence.

So it forces me to use a block to convert artificially a sequence
in an expression.

[
| d |
d := Dictionary new.
d at: #top at: #below1 put: 1.
d at: #top at: #below1 put: 2.
d at: #top at: #below1.
] value

So if I want to build a repl executing expression then this is not a
Pharo repl but just a stupid expression.

I would like to know what would be impact to have sequence and
declaration as expression.

Stef

Reply | Threaded
Open this post in threaded view
|

Re: about expressions

Damien Pollet
Surprising that a sequence is not an expression. I'm pretty sure that (1+2. 2+3) is an expression that returns 5 (after computing a useless addition). What is currently not an expression is the variable declaration, indeed. But if we make |d| an expression then that means we can declare variables in the middle of a sequence… so it would still have the same lifetime, but a shorter scope ?

On 30 June 2017 at 11:32, Stephane Ducasse <[hidden email]> wrote:
I do not get why (Yes I know it is because it is not in the syntax....
but it is conceptually not nice).

| d |
d := Dictionary new.
d at: #top at: #below1 put: 1.
d at: #top at: #below1 put: 2.
d at: #top at: #below1.

is not an expression in Pharo.

It means that I can manipulate

1 + 3,
x + 3 as an expression
but not a sequence.

So it forces me to use a block to convert artificially a sequence
in an expression.

[
| d |
d := Dictionary new.
d at: #top at: #below1 put: 1.
d at: #top at: #below1 put: 2.
d at: #top at: #below1.
] value

So if I want to build a repl executing expression then this is not a
Pharo repl but just a stupid expression.

I would like to know what would be impact to have sequence and
declaration as expression.

Stef




--
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet
Reply | Threaded
Open this post in threaded view
|

Re: about expressions

Stephane Ducasse-3
Ok. Then we can have an ordered expression :)
A sequence without a declaration is a bit useless.


On Fri, Jun 30, 2017 at 11:56 AM, Damien Pollet <[hidden email]> wrote:

> Surprising that a sequence is not an expression. I'm pretty sure that (1+2.
> 2+3) is an expression that returns 5 (after computing a useless addition).
> What is currently not an expression is the variable declaration, indeed. But
> if we make |d| an expression then that means we can declare variables in the
> middle of a sequence… so it would still have the same lifetime, but a
> shorter scope ?
>
> On 30 June 2017 at 11:32, Stephane Ducasse <[hidden email]> wrote:
>>
>> I do not get why (Yes I know it is because it is not in the syntax....
>> but it is conceptually not nice).
>>
>> | d |
>> d := Dictionary new.
>> d at: #top at: #below1 put: 1.
>> d at: #top at: #below1 put: 2.
>> d at: #top at: #below1.
>>
>> is not an expression in Pharo.
>>
>> It means that I can manipulate
>>
>> 1 + 3,
>> x + 3 as an expression
>> but not a sequence.
>>
>> So it forces me to use a block to convert artificially a sequence
>> in an expression.
>>
>> [
>> | d |
>> d := Dictionary new.
>> d at: #top at: #below1 put: 1.
>> d at: #top at: #below1 put: 2.
>> d at: #top at: #below1.
>> ] value
>>
>> So if I want to build a repl executing expression then this is not a
>> Pharo repl but just a stupid expression.
>>
>> I would like to know what would be impact to have sequence and
>> declaration as expression.
>>
>> Stef
>>
>
>
>
> --
> Damien Pollet
> type less, do more [ | ] http://people.untyped.org/damien.pollet