Exercise # 2 - Task # 1 - DSL Syntax confusion

Moderatoren: pmueller, SE - Design and Construction

AizazZaidee
BASIC-Programmierer
Beiträge: 106
Registriert: 20. Apr 2016 22:49

Exercise # 2 - Task # 1 - DSL Syntax confusion

Hi,
following is mentioned in the exercise question...
In this exercise, you have
to specify them in the linearization, but you can insert them together in one step.
Provide the linearization, including all intermediate steps of the algorithm, even for the resolution of the » operator,
for trait D, and the classes E, F, G.
1) What does "you can insert them together in one step"

Does it means that

Code: Alles auswählen

Lin("G", Lin("C")) ===
Lin("G", LinResult("X", "X", "X")) 
can be replaced by

Code: Alles auswählen

Lin("G", LinResult("X", "X", "X"))

2) resolution of the » operator ... How do I provide linearization for this operator?

for example I would do something like this

Code: Alles auswählen

class A { print("A") }
trait H { print("H") }
trait S extends H { print("S") }
trait R { print("R ") }
trait T extends R with H { print("T") }
class B extends A with T with S { print("B") }

new B  // A R H T S B

// lin(B) = B >> lin(S) >> lin(T) >> lin(A)
//        = B >> (S >> H) >> (T >> H >> R) >> A
//        = B >> S >> T >> H >> R >> A 
but I am still not clear what do you mean by linearization of >> operator and how to do it in code with you provided example!

The problem is not what to do it but since there is no documentation or example how to use those methods provided in DSL, I have no idea as how to do it. Please provide example usage of your methods as there are also no test cases so how do I know if I have done something right or wrong?

Thanks,

pmueller
Moderator
Beiträge: 87
Registriert: 25. Jan 2018 11:14

Re: Exercise # 2 - Task # 1 - DSL Syntax confusion

AizazZaidee hat geschrieben:
1. Mai 2018 15:00

1) What does "you can insert them together in one step"
This just concerns Any and AnyRef.
AizazZaidee hat geschrieben:
1. Mai 2018 15:00
2) resolution of the » operator ... How do I provide linearization for this operator?
Maybe you could have a look at the other thread, which contains examples from another student.

Best,
Patrick

labataschö
Windoof-User
Beiträge: 37
Registriert: 15. Apr 2015 16:43

Re: Exercise # 2 - Task # 1 - DSL Syntax confusion

pmueller hat geschrieben:
2. Mai 2018 10:14
Maybe you could have a look at the other thread, which contains examples from another student.
That would be this thread: viewtopic.php?f=234&t=37977

When you encounter something like this:

Code: Alles auswählen

Lin("Foo", >>(LinResult("Bar"), >>(LinResult("Foo", "Bar"), LinResult("Bar", "Foo"))))
you need to first compute the inner linearization result, that is the result of

Code: Alles auswählen

>>(LinResult("Foo", "Bar"), LinResult("Bar", "Foo"))
And as the task description says, you need to do it step by step. Next step in the computation of the inner linearization would hence be (according to the second rule for >>):

Code: Alles auswählen

>>(LinResult("Bar"), LinResult("Bar", "Foo"))

labataschö
Windoof-User
Beiträge: 37
Registriert: 15. Apr 2015 16:43

Re: Exercise # 2 - Task # 1 - DSL Syntax confusion

Just saw that there's also another thread on this: viewtopic.php?f=234&t=37997