last day (24 days later) » 

10:41 AM
.
 
10:53 AM
Hello @Jacob
 
@Mr.Wizard hello!
 
No promises that I will either understand your question or be able to help, but I'm here to listen. :-)
 
nice :)
Btw I think I understand most of what is going on!
And I no longer think there is a bug
 
Would you mind describing that understanding for me?
@Jacob ?
 
Hello, I am sorry, my internet connection failed
 
11:08 AM
Ah, well, glad to have you back in that case.
 
I am in a train right now.. I went through a big tunnel
:)
glad you're still here :)
Ok, I can try to explain the new insight
 
Sounds interesting. I wish I was there.
 
it has to do with the fact that Unevaluated has HoldAllComplete
Hehe it was a tunnel through a "polder"... you know where the Dutch have made land out of water, very... touristical?
My connection may still be bad.
 
No problem; continue as able.
 
In the "towards an answer" comment, I said that mathematica expressions each have some "time of last change" attached to them
Also mathematica keeps track of all symbols in an expression, so that when a symbol gets a new rule attached to it, it can say the expression must have changed
we can see this at work in

Clear[h, somethingElse, something]
h[something, something = somethingElse]

which evaluates to h[something, somethingElse]
but

Clear[h, somethingElse, something]
Identity[h[something, something = somethingElse]]

evaluates to h[somethingElse, somethingElse]
hmm.. I still find it hard to explain. Also I hope my messages are arriving :)
 
11:15 AM
They are, I merely didn't want to interrupt. Have you seen Update? I think it is at least related, in case you missed it.
 
anyway.. to see that these updates are tied to symbols, lets use the following definition
Ah, yeah, I've looked at it once
It made me more way about some uses of Condition :)
But maybe I should look at it again (soon)
Anyway, please let me show that some tracking of changing of expressions is tied to symbols
for this purpose have the definition:
myToExpression[x_ /; IntegerQ[ToExpression[x]]] := ToExpression[x]
We then have

Clear[y]
{myToExpression["y"], y = 5}

-> {myToExpression["y"], 5}
but also

Clear[y]
With[
{expr = Identity[{myToExpression["y"], y = 5}]},
Identity[expr]
]

-> {myToExpression["y"], 5}
 
let me play with that for a minute
 
(Keep writing if you wish; I'll read it soon.)
 
alright
By the way, please feel very free to interrupt. I can see that anytime I tell a long story uninterrupted, it ends up having gaps
 
11:21 AM
OK, please continue.
 
Again in the above the With thing is just to make it more convincing. But really Identity[{myToExpression["y"], y = 5}] evaluating to.. {myToExpression["y"], y = 5} already shows the point
 
Incidentally, before you continue, have you seen Rojo's use of "guard" in Module? It's a clever leverage of this very thing I believe.
 
Okido.. Well.. now.. symbols with HoldAllComplete shield symbols against this kind of symbol tracking.. it seems. Or it prevents the expression from having updates on its "time of last change".. or something :P. I will try to show with an expample
ah no I have not seen that
sounds interesting :)
 
@JacobAkkerboom Please do; this sounds new to me.
 
I think I learned a very nice lesson from all of this. Though I don't know if this is the smartest approach to learning :). But back to the shielding
We can set

ClearAll[myFromHeldExpression]
SetAttributes[myFromHeldExpression, HoldAllComplete];
myFromHeldExpression[x_ /; IntegerQ[x]] := x
and have

{myFromHeldExpression[z], z = 6}

-> {myFromHeldExpression[z], 6}
whereas if we had used HoldAll instead of HoldAllComplete, we would get

ClearAll[myFromHeldExpression]
SetAttributes[myFromHeldExpression, HoldAll];
myFromHeldExpression[x_ /; IntegerQ[x]] := x
{myFromHeldExpression[z], z = 6}

-> {6,6}
 
11:27 AM
I see this behavior now, and no, I don't think I was aware of that.
 
yay :)
I feel so useful
I guess I should have added in my question in the example of g I had also tried to change the value of x, but that didn't cause an "update". Example:
g[x_Symbol]:=x
x=3;
With[{expr=g[Sequence@Unevaluated@x]}
,
x=4;
Identity[expr]
]

-> g[Unevalauted[x]]
 
Wait; I may have spoken too soon. :o Surely you are pushing into the corners of the Mathematica evaluator that I seldom explore. However, my first test is to simply remove that attribute, and I still get {6, 6}:
ClearAll[myFromHeldExpression]
(*SetAttributes[myFromHeldExpression,HoldAllComplete];*)
myFromHeldExpression[x_ /; IntegerQ[x]] := x
{myFromHeldExpression[z], z = 6} // Identity
Is this expected by you?
 
Ah you also have to clear z... maybe?
woops, I forgot that mysefl
 
I still get {6, 6} even if I start with Remove[myFromHeldExpression, z]
 
Ah.. So I may have spoken too soon
Ahh no, I think I am still right :)
 
11:31 AM
Defininately you should speak to Rojo about this, after searching the site for "guard," as he was also exploring these things.
@JacobAkkerboom Please continue. :-)
 
Its always nice to talk to Rojo :)
It is expected to me that

ClearAll[myFromHeldExpression]
(*SetAttributes[myFromHeldExpression,HoldAllComplete];*)

myFromHeldExpression[x_ /; IntegerQ[x]] := x
Clear[z]
{myFromHeldExpression[z], z = 6} // Identity

-> {6,6}

As here we don't have HoldAllComplete, so that we an "update" happens and mathematica evaluates the first argument of list again
 
Excuse me, I'll be back in a few minutes.
 
ok, that's fine
I guess I'll take a peak at guard in the meantime :)
Ahh.. yeah, now that I found your answer with guard in it, I think I recall seeing this before. Anyway it is very Rojo-ish :). With a lot of Condition's and probably also transparancy of Module to Condition... I came across this when fooling around with tail recursion
 
@Jacob I'm back.
 
connection still bad. Welcome back!
wb!
 
11:43 AM
@JacobAkkerboom I'm confused; I thought you were saying that the updates happen with HoldAllComplete, but not without it; now you seem to be saying the opposite.
 
@Mr.Wizard welcome back! My connection is still bad
Oh I am sorry. No I meant to say that HoldAllComplete prevents these updates
 
@JacobAkkerboom Going back to this then, there is no HoldAllComplete, and yet it does not "update" -- how does this fit in?
 
You mean in your example with the argument HoldAllComplete commented out right?
Let assume that we used Clear[z] though
Here I consider an "update" to take place. Mathematica tracks which symbols are present, notes that z has changed and re-evaluates
 
@JacobAkkerboom No, I mean the code you get to if you follow the little left-arrow next to my message (left of "@JacobAkkerboom")
 
Ah, thats a nice trick :P
 
11:49 AM
Sorry, I take certain things for granted; it must have been hard for you to follow certain chat discussions that were heavily linked!
 
Ah... well in this case, there is no symbol present in the expression.. only the string. So mathematica also does not track the symbol and does not realise myToExpression["x"] might now evaluate to something else
Haha yeah I guess :)
 
I am starting to form/refresh my own understanding of the updating evaluation, but I'd like to hear you express the rest of what you had to say without me interrupting again. I'm certainly going to be exploring this in the next few days.
@JacobAkkerboom Good point; I see that now.
 
Haha I now enjoy following your links
Also I'm proud that you would spend time on this :)
Em.. I think I have made most of the points I had really. Let's see if there is something missing
also a warning: my battery is running low. I might suddenly leave :)
15 minutes until I reach my destination by train anyway. Though I would gladly speak more later today if there is something to say :)
 
If you have time/battery: I still have trouble seeing a clear example where HoldAllComplete alone changes the update behavior. Your examples with and without the updating were different in other aspects as well. Can you isolate this?
 
Ok. I'll try. Moment
later you will have to teach me how to link :)
 
11:57 AM
@JacobAkkerboom When you mouse-over a comment you should see a little right-arrow at the bottom right corner; click that to reply to the comment.
 
Lets have

ClearAll[myFromHeldExpression]
SetAttributes[myFromHeldExpression, HoldAllComplete];
myFromHeldExpression[x_ /; IntegerQ[x]] := x

and

ClearAll[myFromHeldExpression2]
SetAttributes[myFromHeldExpression2, HoldAll];
myFromHeldExpression2[x_ /; IntegerQ[x]] := x
{myFromHeldExpression2[z], z = 6}
 
@JacobAkkerboom If I clear z as well they behave the same on my system.
 
We have

Clear[z]
Identity[{myFromHeldExpression[z], z = 6}]

-> {myFromHeldExpression[z], z = 6}

But

Clear[z]
Identity[{myFromHeldExpression2[z], z = 6}]

-> {6,6}
But now my battery is really dead. Gotta go! Hope to catch you later!
We have

Clear[z]
Identity[{myFromHeldExpression[z], z = 6}]

-> {myFromHeldExpression[z], z = 6}

But

Clear[z]
Identity[{myFromHeldExpression2[z], z = 6}]

-> {6,6}
 
Okay, good --- whatever time it is there ---, Jacob!
@JacobAkkerboom FWIW this example finally works; if I clear z along with myFromHeldExpression before the definition they behave the same.
 
 
2 hours later…
2:26 PM
@Mr.Wizard Your remark to take a look at Update was very good indeed. It seems we can speak of an Update instead of an "update" in the above ;). Also consider

gggg[y_Symbol, x_Symbol] := "yay";

Clear[y, x]
First[{gggg[Sequence[y, Unevaluated[x]]], Update[y]}]
-> "yay"

First[{gggg[Sequence[y, Unevaluated[x]]], Update[x]}]
-> gggg[y, Unevaluated[x]]

indeed MMA does not look for x inside Unevaluated :)
@Mr.Wizard I also said I learned a lot investigating these examples. The most important thing I learned is simpler than all this, so you may have seen it, but if not, it is probably nice to compare the following

Trace[{1, 2, 3}, TraceOriginal -> True]
-> {1, 2, 3}

Trace[{1, 2, oki}, TraceOriginal -> True]
-> {{1,2,oki},{List},{1},{2},{oki},{1,2,oki}}

With[
{expr = {1, 2, oki}},
Trace[expr, TraceOriginal -> True]
]

-> {{1,2,oki}}

Mathematica truly remembers what has been evaluated :). Also it does not go through expressions consisting only of basic types like List and Integer.
 

  last day (24 days later) »