- SmugHaskellWeenie: cabal sandbox init, cabal install this, cabal install that, write code, add ghc pragma, wtf! add ghc pragma, wtf! add ghc pragma ... Yeah, it compiles! Job done. Almost, time to get rid of the warnings. add ghc pragma, and another, and one from the top Carol and ... yeah, it compiles with no warnings.
Yeah .5 seconds is way to long, the reason for the animation is that in this game you are looking at the list of functions and only after you are done does your eyes have time to register changes elsewhere. If it has already changed your brain has to try to figure out what has changed when the system can provide hints.
Because you would rapidly move them around changing it to be 0.05 or something just slow enough so that your brain would notice movement above, but not slow enough to impede in trying new things.
Instead of delaying in code, think about having the main loop enter the execution routines of a few FSMs (modem FSM, i/o FSM, etc). In this model, a FSM state function can just return early if it's waiting for an even, giving execution time to other FSMs.
Of course, a better approach would be to run a RTOS on your uC, like the venerable FreeRTOS. Then you can just run tasks that can sleep, communicate via queues, and you can even get preemption if you wish. But I'm not sure it's available for the Arduino.
Additionally, since you're using a SIM90x, why are you polling the modem? Out-of-band events (incoming call, new text message) usually arrive in the form of Unsolicited Messages, like +CMTI for a new SMS or RING for an incoming call. You can interrupt on each character received via UART, and do your processing there.
That's how it works now (the FSM), which is why an interrupt isn't really necessary (the rotary dial state doesn't do anything other than poll for the dialing). Also, it's a bit overkill to load a RTOS for the 50 lines of code this thing has.
The polling of the shield is done because that's the way the shield library works, and I didn't want to rewrite the entire thing when it works fine as it is now, really...
Yes, the use of macros is not always justified in the examples, because Python is quite expressive already.
However, the ability to have macros is orthogonal with the feature set of the language. What is interesting is the ability to inspect and modify a Python AST.
Of course, meta-programming is a way to integrate otherwise absent features of a language as-if they were built-in.
Python is sufficiently dynamic that most things can be done using existing facilities, like reflection and metaobjects (the @case example, as you mention).
But there is a difference between using those facilites at runtime and producing some code at macro-expansion time (this might be relevant for Cython, for example).
You can, for example, define a domain-specific language that is directly translated as Python, and not interpreted like an API-based representation would. You can even apply custom type checking for that DSL.
Or, you could analyze an existing python source code and produce a translation in another language without having to reimplement a parser (see the Python-to-Javascript example, or Common-Lisp's Parenscript).
- SmugCeeWeenie: I am so fast, look (oops, core dumped)
- SmugGoWeenie: abstractions are so nasty we should get rid of functions, so that everyhting is laid out clearly. Hopefully, I have copy/paste.
- SmugAdaWeenie: Functions are not procedures and records cannot store objects. Real engineers do not "prototype" code.
- SmugHaskellWeenie: Yeah, it compiles! Job done.
> In the space year 2015 people are still doing this.
About first class functions? citation needed.