2009/3/14 Sebastien Lelong <[email protected]>: > Hi Joep, > >> The way to do this in C is to >> create a structure with all relevant info in it. But since we don't >> have stuctures eiher, we need to add each relevant var as a calling >> parameter. > > We don't have struct, but we have array. With getters and setters, you can > consider having something behaving like a struct, This takes extra code, but so does passing parameters. I'd say passing parameters should be more efficient but I am not sure. Would be nice to know though ;)
And more general: we are working on embedded systems, so resources are scarce. I did not analyse it yet, but my idea is that both jallib and jalv2 give bigger code then the old compiler + libs. Both the compiler and jallib also add much value to the old situation, but limited resource use is a quality aspect we should not forget... >> In short: if you only have two bits that relate to the object, make >> them calling parameters. > > This is the case here: only two bit parameters (2 pins). But this would give > a weird API. What I want when using this lib is "gimme the distance read by > ranger n°2", and not "using these pins (which appears to identify ranger > n°2), gimme the distance". As a user, I don't even want to know there are > two involved pins, and this can be error prone. I just want to get the > distance, using some kind of abstraction (ranger n°X). Of course we want to help our users as much as we can. But in this case the user has to know about the ranger pins anyway. So it is not a matter of shielding this from the user, where it's defined - at setup-time or when you use them. What could we do? or -------------------------------------------------------------------- ; setup sharp 1 setup_sharp(1, pin_a0, pin_a1) forever loop x= read_sharp(1) end loop or -------------------------------------------------------------------- forever loop x= read_sharp(pin_a0, pin_a1) ; read sharp 1 end loop or -------------------------------------------------------------------- function read_sharp1() return byrte is pragma inline return read_sharp(pin_a0, pin_a1) ; read sharp 1 end function forever loop x= read_sharp1() end loop or -------------------------------------------------------------------- var volatile bit sharp1_in = pin_a0 var volatile bit sharp1_out = pin_a1 forever loop x= read_sharp(sharp1_in, sharp1_out) end loop -------------------------------------------------------------------- Take your pick. And you probably understand by now that I see no added value in the first option that justifies higher resource use. Joep --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jallib?hl=en -~----------~----~----~----~------~----~------~--~---
