## REScala Iterate documentation / slides difference

Assax
Windoof-User
Beiträge: 41
Registriert: 2. Dez 2011 10:38

### REScala Iterate documentation / slides difference

Hello,

I have a question about the Iterate example in the RP2 slides and would like to have an answer on that.

The slides say that the signal is CONSTANT and examples given are always

Code: Alles auswählen

 assert(s.get == 10) 
Now however I checked the documentation and it is COMPLETELY different.
http://www.guidosalvaneschi.com/rescala/main/manual.pdf

There is says that the returned signal holds the value computed by the function f when Event e occurs.

The example given in the documentation is the same codewise, but with a key difference:

Code: Alles auswählen

...
assert(s.get == 11)
...
assert(s.get == 12)
...

So the Signal changes!
Could the organizer please clarify this??

m.hosseinian
Windoof-User
Beiträge: 34
Registriert: 3. Mai 2015 21:28

### Re: REScala Iterate documentation / slides difference

few weeks ago I posted this: viewtopic.php?f=234&t=32573
but, got no reply

Assax
Windoof-User
Beiträge: 41
Registriert: 2. Dez 2011 10:38

### Re: REScala Iterate documentation / slides difference

I hope this will get some attention.. it's not something minor.

Also I am a bit confused on the value the test holds.

From what I gather first it is 10 because that is the init value.
But when we call e(1) that 1 is passed to f as the x argument is it not? So why then does test not become 1 but 11 instead (since the function has " test = x"). Since unlike the fold example the result of F is only based on the input and not on the current state as well.

And after e(2) shouldn't s be 3? Since it says "returns a signal holding the value computed by f" (which is x+1)?

m.hosseinian
Windoof-User
Beiträge: 34
Registriert: 3. Mai 2015 21:28

### Re: REScala Iterate documentation / slides difference

I assume the value of e is irrelevant, it is not passed as f's argument instead, the value of signal is passed. At the end of the f's execution, the value of s is updated to the return value of f and is used for subsequent iterates. As I said, the following snippet holds, I've tested it:

Code: Alles auswählen

var test: Int = 0
val e = new ImperativeEvent[Int]()
val f = (x:Int)=>{test=x; x+1}
val s: Signal[Int] = e.iterate(10)(f)
e(100)
assert(test == 10)
assert(s.get == 11)
e(2000)
assert(test == 11)
assert(s.get == 12)
e(1)
assert(test == 12)
assert(s.get == 13)

Assax
Windoof-User
Beiträge: 41
Registriert: 2. Dez 2011 10:38

### Re: REScala Iterate documentation / slides difference

You are right, thank you.
I just tested it as well ( after finally managing to properly set up sbt for rescala etc etc, this could really use some more documentation imo..) and got the same result.
Also this confirms that the slides are indeed wrong.

I also think it is not clearly explained at all which of the values gets passed to the function when applying iterate (sinec all we know is just that it has to be of the same type as the init value). Though maybe that's just me.

m.hosseinian
Windoof-User
Beiträge: 34
Registriert: 3. Mai 2015 21:28

### Re: REScala Iterate documentation / slides difference

Maybe they're about some older versions... But still wrong and misleading. I, actually, took a look at the documentation when it made little sense to me the way it's described in the slides.

salvaneschi
Mausschubser
Beiträge: 49
Registriert: 29. Mär 2013 23:51

### Re: REScala Iterate documentation / slides difference

Dear All,
thanks for your feedback, we updated the slides with the correct description of iterate.

@Assax
"after finally managing to properly set up sbt for rescala etc etc, this could really use some more documentation imo.."
What do you suggest to document? Currently REScala is just an ordinary sbt project and should only require "sbt compile" to be used..

Assax
Windoof-User
Beiträge: 41
Registriert: 2. Dez 2011 10:38

### Re: REScala Iterate documentation / slides difference

From my personal experience (note I am a first time Scala user and never have done anything with it before neither have I ever got in touch with sbt previously)

My biggest problem was how to get it running without falling back on the exercise files being given.
First I downloaded REscala from the Master branch. At first I did not know what to do what to begin with it. I quickly checked the exercise given to us and found this:

In comparison to the previous exercises it is necessary to first make
REScala locally available for sbt. This is done by checking out REScala from https://github.com/guidosalva/rescala
and running sbt publishLocal
Following this I ran sbt publishLocal inside the root directory of REscala and thought I was all set and done.
I went on to create a new scala file.

For example:
I just wanted to make a quick scala application to test the Iterate function, as stated in the documentation I imported

Code: Alles auswählen

1 import rescala.
2 import rescala.events.
3 import makro.SignalMacro.{SignalM => Signal}

into the application.
Made an object with main and everything required and adapted the code shown on the slides. Trying to run it in sbt quickly resulted in compilation errors:
[error] ...: Not found object rescala
[error] import rescala._
[error] import rescala.events._
[error] ...: Not found: object makro
[error] import makro.SignalMacro ....
[error]not found: type ImperativeEvent
[error]val f = new ImperativeEvent[Int]();
^
! I remembered that there was this thing called build.scala where you had to "disclose" the dependencies. Googling how to find out the libraryDependency in order to put it into a build file did not lead to any helpful results, surely there must be some way to find out something like:
libraryDependencies += "de.tuda.stg" %% "rescala" % "0+"
especially this part
"de.tuda.stg" %% "rescala" % "0+"
.
I had to rely on the Build.scala provided by the exercise in order to get it working. This is where my problem comes in: without copy and pasting necessary files (in this case the Build.scala) I would still have no idea on how to make my own scala project with REscala. Should I ever have to use another external project I would probably have no idea how to properly use it.

Please don't get me wrong, this might not even be an issue with REScala's documentation. The "could really use some more documentation" was more based on the exercise / in general.
Maybe the problem even lies in my own misunderstanding in how to define build files for sbt or how to use sbt properly in general (except for the run and eclipse commands).

salvaneschi
Mausschubser
Beiträge: 49
Registriert: 29. Mär 2013 23:51

### Re: REScala Iterate documentation / slides difference

Thanks a lot for the feedback.
That will help to improve the lecture