alice-teacher Alice Array Elements calling Methods

Daniel Abeshouse dabeshou at andrew.cmu.edu
Mon May 6 11:18:26 EDT 2019


This is a bug. Thanks for finding it.
The runtime insertion code for array has an error in the type handling.
It stores the Automobile as an STransport instance and pulls it out as that type as well, which breaks when invoking a method on Automobile.
A localized fix is not difficult, but I will add some further checks and work to prevent breaking other things.
It will be included in the next release.

--
Daniel Abeshouse
Alice Project
Carnegie Mellon University
On May 6, 2019, 8:36 AM -0400, Donald Slater <djslater107 at mac.com>, wrote:
> Terri,
> It is the craziest thing and I believe that you have found a bug.
>
> It turns out that if I use the array “allCars”, the program will recognize and execute the drive procedure.
>
> You have set up these supplemental arrays of Automobiles to keep track of the different rows of cars. You initialize these arrays with the black car, and then in setup successfully populate these arrays with random sets of cars, replacing the black car with different automobiles from the scene.
>
> The setup works as you would expect If you print these row arrays, you see the different cars.
>
> The bug seems to occur in that for some reason, even though these are arrays of automobiles, in the linking of the random car to the array, Alice loses track of the fact that there are methods associated with that object (in this case, drive), and simply ignores the call to that method. There may be a type problem here in that Alice uses SThing somehow in the reassignment of an object to an array of objects, but that is only speculation on my part, and the dev team may have more to say about this.
>
> Another workaround, you have already found one, would be that your row arrays could be arrays of WholeNumbers, storing random indices from allCars rather than the car object. Then you could use the allCars array with the index values from these row arrays to call drive.
>
> I have attached your original world (I have added a couple of statements to help me with debugging), plus a test world I built to help me check my hypothesis, for the dev team to look at. I will be interested to see if they have any other thoughts.
>
> Thank you, and all the best,
> Don Slater
>
> Alice Project
>
>
>
> > On May 5, 2019, at 10:21 PM, Kelly, Terri <kellyt at bishopireton.org> wrote:
> >
> > Don,
> >
> > I tried to recreate it in a simple world and ... it worked.  So... there must be something in this crazy world.
> >
> > There is a second problem that I would appreciate you taking a minute to look at.
> >
> > So - the first problem is the calling of a class method from an item in an array ... the method I am trying to call is an automobile method named drive.  I am calling it from the scene level method moveRow, which is called from myFirstMethod after setup is done. Setup appears to work properly and I have put in several say statements to narrow down the problem.
> >
> > The second issue is the event listener, collision... when I run this world, it takes FOREVER to return from running, unless I comment out the event listener.  The event listener worked great when there was just a small array of automobiles (5 in number), but when I added the other 15 ... it just almost seems to hang when returning from running...  It doesn't actually hang - it just takes forever to come back.
> >
> > I recreated the entire world (everything) in a new Alice world and ... created 4 collision event listeners each with an array of just 4 items and ... the delay in ending execution occurred again.
> >
> > Thanks,
> >
> > Terri KElly
> > Computer Science
> > Bishop Ireton
> >
> >
> > > On Sun, May 5, 2019 at 6:00 PM Donald Slater <dslater at andrew.cmu.edu> wrote:
> > > > Terri,
> > > > Would you mind sending a copy of your program? I am trying to recreate the problem based on your description, but I do not think I am getting it right, as everything seems to be working for me… I must be missing something…
> > > >
> > > > Also, I am using the latest download of Alice available on alice.org (3.5). We added set and get indexed value into procedure and function list for all array properties, but I do not think that is related to your issue. But if you are using an older version of Alice you might try it.
> > > >
> > > > Looking forward to hearing from you.
> > > >
> > > > All the best,
> > > > Don Slater
> > > >
> > > > Alice Project
> > > >
> > > > > On May 4, 2019, at 4:27 PM, Kelly, Terri <kellyt at bishopireton.org> wrote:
> > > > >
> > > > > I have a world which is not behaving like I am expecting it to.
> > > > >
> > > > > I have an array of automobiles called rowA[]
> > > > > I have a method created for automobiles called go
> > > > > In go, the first thing I have this do is say it's Sthing (this say "" + SThing this)
> > > > >
> > > > > If I call go with blueTruck, it works fine, the truck says blueTruck and then moves forward
> > > > >
> > > > > blueTruck.go()
> > > > >
> > > > > If I call go with rowA[0].go ... Alice hangs,
> > > > >
> > > > > So, from the test method I have
> > > > >
> > > > > blueTruck.go()
> > > > > rowA[0] = blueTruck
> > > > > rowA[0].say "" + Sthing rowA[0]
> > > > > rowA[0].go
> > > > >
> > > > > Is there any reason why I should not be able to call a class level method from an array that is of that type class?
> > > > >
> > > > > Terri Kelly
> > > > > Computer Science
> > > > > Bishop Ireton High School
> > > > > Alexandria, VA
> > > > >
> > > > > The information contained in this communication may be subject to legal confidentiality protection or privilege. It is intended solely for use by the intended recipient and others authorized to receive it. If you have received this communication in error, please notify the sender and delete it immediately. You are hereby notified that any disclosure, copying, distribution or taking action in reliance of the contents of this information is strictly prohibited and may be unlawful.  The school accepts no liability whatsoever for any damage, loss, or expense arising from any misuse of this e-mail and/or from the accessing of any files attached to this e-mail._______________________________________________
> > > > > alice-teachers mailing list
> > > > > alice-teachers at lists.andrew.cmu.edu
> > > > > To change settings or unsubscribe visit:
> > > > > https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers
> > > >
> > > > _______________________________________________
> > > > alice-teachers mailing list
> > > > alice-teachers at lists.andrew.cmu.edu
> > > > To change settings or unsubscribe visit:
> > > > https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers
> >
> > The information contained in this communication may be subject to legal confidentiality protection or privilege. It is intended solely for use by the intended recipient and others authorized to receive it. If you have received this communication in error, please notify the sender and delete it immediately. You are hereby notified that any disclosure, copying, distribution or taking action in reliance of the contents of this information is strictly prohibited and may be unlawful.  The school accepts no liability whatsoever for any damage, loss, or expense arising from any misuse of this e-mail and/or from the accessing of any files attached to this e-mail.<Frogger.a3p>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.andrew.cmu.edu/pipermail/alice-teachers/attachments/20190506/4d5be88f/attachment.html>


More information about the alice-teachers mailing list