Ginger supports type annotations as part of it’s design by contract support. These contracts may be enforced or checked at compile time if enough type information is available, otherwise they are checked at runtime. Type annotations can become part of the signature for the function (thus allowing overloading) for required arguments (but not optional and residual arguments). Consider this example:
1
2
3
4
5
| define add (a b)
require (is a <number>)
require (is b <number>)
ensure (is result <number>)
+ a b |
We can of course make a type requirement for an optional third parameter but since it is optional it inherently makes the signature ambiguous and thus doesn’t count toward the function signature used in overloading functions. It still remains part of the contract though and would be enforced and in optimized production code allows the compiler to make useful assumptions.
1
2
3
4
5
6
| define add (a b optional: (c 100))
require (is a <number>)
require (is b <number>)
require (is c <number>)
ensure (is result <number>)
+ a b c |
Posted in Uncategorized | 1 Comment »
I have finalized how function signatures should work in Ginger. My Ginger to Scheme compiler basically mirrored Scheme’s argument conventions but I’ve put a little more thought into it for the Ginger to C compiler. First an example where arguments are not named:
1
2
3
4
| define foo (a b)
noop
foo "A argument" "B argument" |
The same function, foo, implicitly defines named arguments so the following also works:
1
| foo b: "B argument" a: "A argument" |
Now consider the definition of optional arguments:
1
2
3
4
5
| define foo (a optional: (b "B argument"))
noop
foo "A argument"
foo "A argument" b: "B argument 2" |
And finally unnamed arguments are captured as a residual (called rest in many other languages):
1
2
3
4
| define foo (a optional: (b "B argument") residual: c)
noop
foo a: "A argument" b: "B argument 2" "and this" "and that" "and even" 1000 |
Posted in Ginger | No Comments »
My truck has been unusable for a couple of months now. The master clutch cylinder and the slave cylinder were in such bad repair the clutch goes all the way to the floor and it had become impossible to switch gears. I was planning to fix it myself but when I realized I would have to drop the transmission to replace the two cylinders, I thought better of the idea. I had it towed into the shop on Friday.
We have been missing it for a while. Last weekend we were planning on going out to Grand Falls but without the truck we had to take my Saturn. We made it about 40 yards in the Saturn on “Indian Road 70″ before thinking better of the idea. The last leg of the journey to Grand Falls is pretty rough. It’s not so much that you need four wheel drive as you need a vehicle with tough suspension, a large wheel radius and the ability to take a few rocks to the head.
Something like my own F350 diesel behemoth.. I got a call from the mechanic this afternoon that my truck was ready. In turn, I called Yaya and asked her if she was up for trying out Grand Falls one more time. We headed out after work and made it just before sun set. The bumps and rocks near the end of the trip were the worst and reminded Yaya of the “Pink Jeep Tours” you can take near Sedona. This was more of a Black Truck Tour.
Yaya has some great shots on her blog but since it’s private I will go ahead and repeat them here:




Posted in Life | No Comments »
These Doctor Who felt dolls by AGirlCalledRic are outrageously cute! I found her work on Etsy which is the ebay of all things homemade.
Posted in Entertainment, DIY | 1 Comment »
Shuttle has updated their web page with what may very well be my next computer. The KPC is small, lean and green. It sucks 33W of power when idle and 55W when going full bore (that’s better than my MacBook). AND it has customizable faceplates.
Posted in Life | 1 Comment »
I have committed some preliminary work towards an “eval” function. The function itself is more or less complete except that it runs into an architectural flaw in ginger. Currently, ginger takes advantage of the fact that Scheme’s representation of functions and variable names work very similarly to her own and she purposefully maps between the two which would be fine except this mapping happens at compile time. Eval being an inherently run-time kind of thing needs this same mapping to happen at run time. Which I could do.. But it would be wasted code. Ginger needs her own way of looking up functions, namespaces and scope independent of the scheme runtime. In part, this is necessary to support ad-hoc polymorphism which will be much more natural and automatic in Ginger than it is in Scheme.
Why am I working on eval? With eval implemented, macros are easy. With macros implemented, everything else is easy.
Posted in Ginger | No Comments »
For the past few years Yaya and I have had two TiVos. One original Series 2 with a 120G drive and one Humax with an 80G drive and an integrated DVD player and recorder. We really like the DVD player to the point that it would seem almost a loss to upgrade to a series 3 and lose the ability to play DVDs! We bought an HD TV only when our last TV’s image had gotten so discolored and blurry that each time we watched TV we questioned if our vision was going. But I am too thrifty to pay a premium for cable service or satellite service to get HD and then pay even more to get a series 3 TiVo to record it.. No, HD will have to take me kicking and screaming. But I digress..
The two TiVos were fine but it did cost extra money. The extra $6 for the extra TiVo service and an extra $5 for satellite service and an extra 40-50 watts of electricity being consumed 24/7. The obvious TiVo to retire was the original Series 2 but my 80G Humax is just a bit underpowered in terms of space. I could probably justify buying a hard drive and claim a 1 year payback on my investment but I already had a spare 250G drive gathering dust in a closet so it’s just a matter of coming up with the time to do it. And I have actually been meaning to do this for over a year but almost everything else was higher priority. Sometimes you have to say screw priority, lets just do it.
I started with this HOWTO whose shear length made me question the practicality and wisdom of an upgrade but once you trim out all the information that doesn’t apply to your TiVo, ignore all the warnings and information written for people who have never opened a computer and then do the upgrade process via Ubuntu instead of the boot disk (which I never got working) you really have a pretty short list of things that have to be done:
- Open case and remove drive.
- Put drive on your linux box.
- Run the mfstools command to backup the drive.
- Put new drive on your linux box.
- Run the mfstools command to restore and expand to the new drive.
- Reinstall drive in TiVo and close her up.
Easy peasy.
Posted in DIY | 3 Comments »
I have hastily put together a Ginger development site at Ging3r.org. Almost the only thing there is the Ginger repository which I am hosting with Mercurial.
My first official commit to the repository adds supports for includes. You can now say
1
| include "utility-functions.gin" |
and it does what you probably expect it would do. There are several ways this could be implemented. We could (a) “include” the file during the parse step, (b) include it immediately after the parse step or (c) make it an actual function that glues the code into the runtime environment.
C-style #includes employ technique (a) as the c preprocessor effectively “pastes” in the include before the file is parsed. PHP style includes work very similar to (c) and allow conditional file loading. For now, Ginger uses approach (b). It looks for includes in the parse tree and then parses each included file it discovers and glues the subsequent parse trees into the parent parse tree.
Posted in Ginger | No Comments »
When I was a kid I used to love listening to radio dramas like “The Shadow” and “The Green Hornet.” This was the 80s not the 40s so I was listening to these shows on cassette tapes. I’ve always liked the audio drama format - lately I’ve had more time and more inclination to listen to the radio (time-shifted onto an ipod) than TV. My favorite radio station is BBC Radio 7. BBC 7’s charter is to be an outlet for the BBC’s vast archives of audio content but they also serve a fair bit of original content as well.
One bit of original work, The Scarifyers, is particularly entertaining. Imagine the X-Files set in the 30s in the heart of London and Sculley and Mulder are replaced with an eccentric English professor and a past-his-prime police officer. Maybe it’s more Ghostbusters than X-Files. Regardless, it’s witty writing with clever acting.
I started listening to one drama on 7 called “Hordes of the Things” and have to admit I didn’t get too far before I got bored of it. It’s from many of the same people that brought Hitchiker’s Guide to the Galaxy (HHGTG) to life and there was much hope it would be the next HHGTG. That it is not but let me be bold and say that a new drama on 7 called “Undone” might just be. There’s very little similarity between Undone and Douglas Adam’s HHGTG but for some reason Undone just reminds me of the fun and imagination of HHGTG.
There are still a few episodes left of the second Undone series (Sundays) and the third installment from the Scarifyers is expected this Spring. I always look forward to reading what’s coming up on BBC 7.
Posted in Entertainment | No Comments »
As part of an attempt to simplify my life and keep my friends happy, I’ve been outsourcing a lot of tiger’s functionality as mentioned here. And it seems I moved things just in time - or mostly in time. Tektonic had a network meltdown on Thursday and was down for nearly 24 hours. I haven’t documented them all in my journal but we have had a lot of downtime with tektonic; *much* more than when I had a little box rattling around at the Planet.
Anyway, email got transferred to Google just in time. Unfortunately, web hosting wasn’t transferred to slicehost quick enough. But after a weekend of copying and configing, tiger is back. Hopefully better than ever.
Posted in Life | 1 Comment »