Re: [Plastic-devs] Casting problems (was Re: Plastic and Aladin)
Brought to you by:
johndavidtaylor,
thomasboch
|
From: Mark T. <m.b...@br...> - 2006-05-04 15:36:20
|
On Thu, 4 May 2006, Alasdair Allan wrote: > All, > > I thought this was at the point where it should go to the list... > > For context I was having problems getting Aladin to respond to some, > but not all, pointAtCoords messages sent from my Perl client via the > Hub. Most were successful, but some failed for no apparent reason... > > Thomas Boch wrote: > > Alasdair Allan wrote: > >> Alasdair Allan wrote: > >>> The 20 & 75 is correct and is the requested RA&Dec is decimal > >>> degrees (ie RA 1:20:00.0, Dec 75:00:00)... > >> > >> Ah ha! It's a casting problem, Perl is of course a non-strictly > >> typed language. So when it seems 20.0, it just drops the .0 > >> portion, so the 20.0 getting sent (as a double) to the Hub turns > >> into a Integer, so Aladin isn't happy. When I explicitly cast it > >> as a double everything is fine (which explains why it was working > >> sometimes and not others)! > > > > You are right, Aladin complains with a ClassCastException as it is > > waiting for a Double ! I wonder if the hub shouldn't take care of > > this kind of casting problems ... > > Now there's a thought, it would certainly improve interoperability. > More work on the Hub end though... If I understand the problem and proposed solution correctly, this couldn't work without substantial changes to the standard, since the hub, by design, does not understand the content or argument list types of the messages which it forwards. Hence it can't know whether the stream of <double> elements it has received from a client is in fact supposed to be <int>s. Its job is simply to act as a multiplexer forwarding RPC calls unchanged between senders and recipients. > > I mean : it would of course add complexity on the hub side, but > > Perl developpers don't want to explicitly cast, do they ? Laziness may be a virtue, but you can take it too far. > No, it's actually a real pain in the backside to do casting and there > is the odd corner case where it isn't going to work. For instance > I've yet to figure out how to actually cast to a bool so I can send > back a true/false response to a message (just sending a a1 or a 0 > doesn't seem to cut it and Perl doesn't have a boolean type at all). If there's not a way to do this in whatever module you're using for sending XML-RPC messages, that has to be seen as a deficiency in that module. Check the docs || get the author to fix it || write an XML-RPC module yourself. Mark -- Mark Taylor Astronomical Programmer Physics, Bristol University, UK m.b...@br... +44-117-928-8776 http://www.star.bris.ac.uk/~mbt/ |