[CCC DEV] Concerning commit 6894(ish)

Fred Barnes F.R.M.Barnes at kent.ac.uk
Mon Jul 19 23:07:13 BST 2010


Hi Drew,

> Hey all,
>     I think I'm trying to do something that Occam can't do.
>     In an effort to round out our API and the usability of the
> transterpreter on arduino-like boards, I'm putting together a wiring.module
> that should look just about exactly like arduino.cc's wiring. The problem
> I'm facing is that arduino.cc seems to be taking some advantage of global
> variables.
>     In an attempt to mimic this behavior, right below all the module
> constants, I've written
>
> INITIAL INT ADC.REF IS #0:
>
>     Further down, I have a PROC that sets ADC.REF to the argument passed to
> said PROC, and finally I have the FUNCTION that makes the call
>
> adc.base (avr.pin, ADC.REF, val)
>
>     This does not work.
>     Thoughts?

I assume you mean that you have a FUNCTION which is calling a PROC to try
and change the value of a global variable?  If so, yes, that won't work.
Functions must be side-effect free, i.e. must not change any state outside
of themselves.  If you have a FUNCTION that wants to modify some global
state, it should return it and set it that way (although I'd imagine the
resulting code in this case to look somewhat contorted).


Cheers,

-- Fred
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 185 bytes
Desc: not available
URL: <http://www.concurrency.cc/pipermail/developers/attachments/20100719/e340f900/attachment.pgp>


More information about the developers mailing list