Specification for expressions

29 views
Skip to first unread message

Scheme apprentice

unread,
Oct 17, 2011, 2:55:24 AM10/17/11
to EOPL3
In Chapter 4 the language specification is modified to incorporate
stores.

For any expression what is the criteria that an expression modifies a
store? and for what other criteria one can infer that the state of the
store does not get modified?


For instance, the diff-exp on page 107 takes in two expressions. Each
expression is evaluated separately and can have an effect on some
store. So the first expression may result in a new store σ1 and the
second expression evaluated with store state σ1 may result in a new
store σ2.

The if-exp has 3 expressions. The first expression may result in a new
store state σ1, but why the other expressions when evaluated do not
result in a new store state?

In my opinion, I see that it is more practical to change the store
state in exp2 or exp3, and it is less likely that a conditional will
change the store state.



Also, for the const expression why cant the designer of the language
modify a store? This may not be useful or practical, but is it only
because of practicality or semantics that we do not modify the store
state or is it for a reason of which I do not know?

Thanks in advance.

Mitchell Wand

unread,
Oct 18, 2011, 1:17:40 PM10/18/11
to eo...@googlegroups.com
2011/10/17 Scheme apprentice <sala...@gmail.com>

In Chapter 4 the language specification is modified to incorporate
stores.

For any expression what is the criteria that an expression modifies a
store? and for what other criteria one can infer that the state of the
store does not get modified?

A newref-exp or setref-exp change the store (sec 4.2.2).
A const-exp is an atomic expression that does not change the store.
All other expressions merely propagate any changes in the store that are made by their subexpressions. 


For instance, the diff-exp on page 107 takes in two expressions. Each
expression is evaluated separately and can have an effect on some
store. So the first expression may result in a new store σ1 and the
second expression evaluated with store state σ1 may result in a new
store σ2.

The if-exp has 3 expressions. The first expression may result in a new
store state σ1, but why the other expressions when evaluated do not
result in a new store state?

The other expressions may certainly change the store, and that changed store will become the store reported by the if expression  (top of p. 108). 

In my opinion, I see that it is more practical to change the store
state in exp2 or exp3, and it is less likely that a conditional will
change the store state.

It is surely unusual, but it is still possible for a predicate to have a side effect that changes the store. 



Also, for the const expression why cant the designer of the language
modify a store? This may not be useful or practical, but is it only
because of practicality or semantics that we do not modify the store
state or is it for a reason of which I do not know?

What change would you make?

Hope that helps.

--Prof. Wand 


Scheme apprentice

unread,
Oct 19, 2011, 3:56:44 PM10/19/11
to EOPL3
Thanks a lot for your response.

I still have a couple of questions if you do not mind answering them.

First, only the expressions that return atomic values are placed on
top of the horizontal line.?.?

The if-exp on page 108.

exp1 returns the atomic values: #t, #f, so it is placed on top since
it can also modify the state the right hand side indicates that.
Is this reasoning correct?

Now the other two expressions may also modify the state but since they
do not "necessarily" return an atomic value, they return expressions
instead, the specification of those expressions is not specified (in
the antecedents section). They are however specified in a generic way
(value-of exp env state) under the horizontal line.
Is this reasoning correct?

So if we take the specifications for begin nothing would be present as
the antecedent since all expressions do not return atomic values.
Similarly for the list expression.

exp1 and exp2 in the diff-exp return numbers, similarly the setref
expressions which returns a location and null, both are present above
the line.

I am trying to deduce the rules for specifications from the examples
given, and this is the only pattern I have seen.

I would have thought that for the if-exp we would have three entries
above the line and look something like this:
(value-of exp1 rho sigma0) = (val1, sigma1)
(value-of exp2 rho sigma1) = v2 ;; v2 is a value-store pair
(value-of exp3 rho sigma1) = v3 ;; v3 is a value-store pair
___________________________________________________



Thanks again for all your time.

On Oct 18, 1:17 pm, Mitchell Wand <w...@ccs.neu.edu> wrote:
> 2011/10/17 Scheme apprentice <salal...@gmail.com>
Reply all
Reply to author
Forward
0 new messages