Stuck at lookup implementation in "Building ObjVlisp" tutorial
Hello everyone, I'm new on this mailing list, this is my first mail :-) I'm a student from University of Lille (France). I'm studying this tutorial (I'm using Pharo 4 but it seems not to be a problem): http://sdmeta.gforge.inria.fr/Teaching/ObjVLisp/ObjV.pillar.pdf. I'm working with the "ObjVLispSkeleton-StephaneDucasse.1" image loaded from this repository: MCSmalltalkhubRepository owner: 'StephaneDucasse' project: 'ObjVLispSkeleton' user: '' password: '' I'm stuck at "Method Lookup" p11. First, it seems that unit tests "testNilWhenErrorInLookup" and "testRaisesErrorSendWhenErrorInLookup" are not provided, thus I'm not sure that I'm working with the right image (everything was fine until p11 though). Then, the "lookup: selector" is not provided neither. While there is another method named "lookup: selector from: anObjObject", I can't figure out what I'm supposed to do with the second parameter. Here is what I would do: lookup: selector "look for the method named <selector> starting in the receiver. The lookup is done for a message sent to <anObjObject>. self is an objClass" ^ self objMethodDict at: selector ifAbsent: [ self objSuperclassId ifNotNil: [ self objSuperclass lookup: selector ] ] Could someone tell me if this implementation is correct? If it's correct, what do you think the second parameter is for? Moreover, do you think I'm working with the right image? Thanks. - Edouard
Hi Edward, Le 19/11/2015 13:50, Edouard Delbar a écrit :
Hello everyone,
I'm new on this mailing list, this is my first mail :-)
I'm a student from University of Lille (France). I'm studying this tutorial (I'm using Pharo 4 but it seems not to be a problem): http://sdmeta.gforge.inria.fr/Teaching/ObjVLisp/ObjV.pillar.pdf. I'm working with the "ObjVLispSkeleton-StephaneDucasse.1" image loaded from this repository:
I did ObjVLisp on Pharo4. There is some problems in the PDF but this is the right version of Pharo.
MCSmalltalkhubRepository owner: 'StephaneDucasse' project: 'ObjVLispSkeleton' user: '' password: ''
I'm stuck at "Method Lookup" p11. First, it seems that unit tests "testNilWhenErrorInLookup" and "testRaisesErrorSendWhenErrorInLookup" are not provided, thus I'm not sure that I'm working with the right image (everything was fine until p11 though). Then, the "lookup: selector" is not provided neither. While there is another method named "lookup: selector from: anObjObject", I can't figure out what I'm supposed to do with the second parameter. Here is what I would do:
I remember that some tests was missing and that I had some problems with this method too.
lookup: selector "look for the method named <selector> starting in the receiver. The lookup is done for a message sent to <anObjObject>. self is an objClass" ^ self objMethodDict at: selector ifAbsent: [ self objSuperclassId ifNotNil: [ self objSuperclass lookup: selector ] ]
Could someone tell me if this implementation is correct? If it's correct, what do you think the second parameter is for?
This implementation is correct in my opinion. I did the same. I think the second parameter is an error if this tutorial.
Moreover, do you think I'm working with the right image?
Yes you are.
Thanks.
- Edouard
-- Cyril Ferlicot http://www.synectique.eu 165 Avenue Bretagne Lille 59000 France
Hi edouard I will check as soon as I get some time.
I'm new on this mailing list, this is my first mail :-) welcome
I'm a student from University of Lille (France). I'm studying this tutorial (I'm using Pharo 4 but it seems not to be a problem): http://sdmeta.gforge.inria.fr/Teaching/ObjVLisp/ObjV.pillar.pdf. I'm working with the "ObjVLispSkeleton-StephaneDucasse.1" image loaded from this repository:
MCSmalltalkhubRepository owner: 'StephaneDucasse' project: 'ObjVLispSkeleton' user: '' password: ''
I'm stuck at "Method Lookup" p11. First, it seems that unit tests "testNilWhenErrorInLookup" and "testRaisesErrorSendWhenErrorInLookup" are not provided, Mark if you read this mail. Did you get problem when you did it?
thus I'm not sure that I'm working with the right image (everything was fine until p11 though). Then, the "lookup: selector" is not provided neither.
Not providing lookup: is ok since you have to define it. I will look for the tests in my version.
While there is another method named "lookup: selector from: anObjObject", I can't figure out what I'm supposed to do with the second parameter. What you should see is that the second argument is is provided here because when you raise an error, you should send a messageNotUnderstood and this message should be sent to the original object that received the message and not the class where the method was found. So lookup will use the receiver to walk through the inheritance chain and the from: argument in case of error
Here is what I would do:
lookup: selector "look for the method named <selector> starting in the receiver. The lookup is done for a message sent to <anObjObject>. self is an objClass" ^ self objMethodDict at: selector ifAbsent: [ self objSuperclassId ifNotNil: [ self objSuperclass lookup: selector ] ]
what do you return when you do not find the class
Could someone tell me if this implementation is correct? If it's correct, what do you think the second parameter is for?
Moreover, do you think I'm working with the right image?
Thanks.
- Edouard
Thanks for the reply.
>Â what do you return when you do not find the class
I guess you are talking about this block: "[Â self objSuperclassId ifNotNil: [ self objSuperclass lookup: selector ]]". This code is based on the assumption that the entire block returns "nil" when "self objSuperclassId" is "nil". I'm going to check if my assumption was right.
- Edouard
On Thursday, November 19, 2015 8:17 PM, stepharo <stepharo@free.fr> wrote:
Hi edouard
I will check as soon as I get some time.
I'm new on this mailing list, this is my first mail :-)
welcome
I'm a student from University of Lille (France). I'm studying this tutorial (I'm using Pharo 4 but it seems not to be a problem):Â http://sdmeta.gforge.inria.fr/Teaching/ObjVLisp/ObjV.pillar.pdf. I'm working with the "ObjVLispSkeleton-StephaneDucasse.1" image loaded from this repository:
MCSmalltalkhubRepository owner: 'StephaneDucasse' project: 'ObjVLispSkeleton' user: '' password: ''
I'm stuck at "Method Lookup" p11. First, it seems that unit tests "testNilWhenErrorInLookup" and "testRaisesErrorSendWhenErrorInLookup" are not provided,
Mark if you read this mail. Did you get problem when you did it?
thus I'm not sure that I'm working with the right image (everything was fine until p11 though). Then, the "lookup: selector" is not provided neither.
Not providing lookup: is ok since you have to define it. I will look for the tests in my version.
While there is another method named "lookup: selector from: anObjObject", I can't figure out what I'm supposed to do with the second parameter.
What you should see is that the second argument is is provided here because when you raise an error, you should send a messageNotUnderstood
and this message should be sent to the original object that received the message and not the class where the method was found.
So lookup will use the receiver to walk through the inheritance chain and the from: argument in case of error
Here is what I would do:
lookup: selector "look for the method named <selector> starting in the receiver. The lookup is done for a message sent to <anObjObject>. self is an objClass" ^ self objMethodDict at: selector ifAbsent: [ self objSuperclassId ifNotNil: [ self objSuperclass lookup: selector ] ]
what do you return when you do not find the class
Could someone tell me if this implementation is correct? If it's correct, what do you think the second parameter is for?Â
Moreover, do you think I'm working with the right image?
Thanks.
- Edouard
I checked testNilWhenErrorInLookup "(self selector: #testNilWhenErrorInLookup) run" self assert: (pointClass lookup: #zork) isNil. "The method zork is NOT implement on pointClass" testRaisesErrorSendWhenErrorInLookup "(self selector: #testRaisesErrorSendWhenErrorInLookup) run" self should: [ pointClass send: #zork withArguments: { aPoint } ] raise: Error. "Open a Transcript to see the message trace" Le 19/11/15 13:50, Edouard Delbar a écrit :
Hello everyone,
I'm new on this mailing list, this is my first mail :-)
I'm a student from University of Lille (France). I'm studying this tutorial (I'm using Pharo 4 but it seems not to be a problem): http://sdmeta.gforge.inria.fr/Teaching/ObjVLisp/ObjV.pillar.pdf. I'm working with the "ObjVLispSkeleton-StephaneDucasse.1" image loaded from this repository:
MCSmalltalkhubRepository owner: 'StephaneDucasse' project: 'ObjVLispSkeleton' user: '' password: ''
I'm stuck at "Method Lookup" p11. First, it seems that unit tests "testNilWhenErrorInLookup" and "testRaisesErrorSendWhenErrorInLookup" are not provided, thus I'm not sure that I'm working with the right image (everything was fine until p11 though). Then, the "lookup: selector" is not provided neither. While there is another method named "lookup: selector from: anObjObject", I can't figure out what I'm supposed to do with the second parameter.
Ok I checked in the other method is old the new one should be lookup: selector "look for the method named <selector> starting in the receiver. The lookup is done for a message sent to <anObjObject>. self is an objClass"
Here is what I would do:
lookup: selector "look for the method named <selector> starting in the receiver. The lookup is done for a message sent to <anObjObject>. self is an objClass" ^ self objMethodDict at: selector ifAbsent: [ self objSuperclassId ifNotNil: [ self objSuperclass lookup: selector ] ]
Could someone tell me if this implementation is correct? If it's correct, what do you think the second parameter is for?
Moreover, do you think I'm working with the right image?
Thanks.
- Edouard
Hi, I found "testNilWhenErrorInLookup" indeed, sorry for that. "testRaisesErrorSendWhenErrorInLookup" is still missing though. Maybe the name has changed to this one: testMethodNotFoundRaiseError "(self  run: #testMethodNotFoundRaiseError)" self should: [aPoint unarySend: #zork] raise: Error. About the lookup method, I should not use "lookup: selector from: anObjObject" at all right? - Edouard On Thursday, November 19, 2015 8:24 PM, stepharo <stepharo@free.fr> wrote: I checked testNilWhenErrorInLookup    "(self selector: #testNilWhenErrorInLookup) run"       self assert: (pointClass lookup: #zork) isNil.    "The method zork is NOT implement on pointClass"    testRaisesErrorSendWhenErrorInLookup    "(self selector: #testRaisesErrorSendWhenErrorInLookup) run"       self should: [ pointClass send: #zork withArguments: { aPoint } ] raise: Error.    "Open a Transcript to see the message trace" Le 19/11/15 13:50, Edouard Delbar a écrit : Hello everyone, I'm new on this mailing list, this is my first mail :-) I'm a student from University of Lille (France). I'm studying this tutorial (I'm using Pharo 4 but it seems not to be a problem): http://sdmeta.gforge.inria.fr/Teaching/ObjVLisp/ObjV.pillar.pdf. I'm working with the "ObjVLispSkeleton-StephaneDucasse.1" image loaded from this repository: MCSmalltalkhubRepository owner: 'StephaneDucasse' project: 'ObjVLispSkeleton' user: '' password: '' I'm stuck at "Method Lookup" p11. First, it seems that unit tests "testNilWhenErrorInLookup" and "testRaisesErrorSendWhenErrorInLookup" are not provided, thus I'm not sure that I'm working with the right image (everything was fine until p11 though). Then, the "lookup: selector" is not provided neither. While there is another method named "lookup: selector from: anObjObject", I can't figure out what I'm supposed to do with the second parameter. Ok I checked in the other method is old the new one should be lookup: selector    "look for the method named <selector> starting in the receiver.    The lookup is done for a message sent to <anObjObject>. self is an objClass"    Here is what I would do: lookup: selector "look for the method named <selector> starting in the receiver. The lookup is done for a message sent to <anObjObject>. self is an objClass" ^ self objMethodDict at: selector ifAbsent: [ self objSuperclassId ifNotNil: [ self objSuperclass lookup: selector ] ] Could someone tell me if this implementation is correct? If it's correct, what do you think the second parameter is for? Moreover, do you think I'm working with the right image? Thanks. - Edouard
participants (3)
-
Edouard Delbar -
Ferlicot D. Cyril -
stepharo