<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5144379</id><updated>2012-02-01T21:38:59.801Z</updated><category term='cooking'/><category term='ppuk'/><category term='research'/><category term='gEDA'/><title type='text'>Peter Brett's Blog</title><subtitle type='html'>Peter Brett's website news, random thoughts and articles on space technology...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.peter-b.co.uk/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default?start-index=26&amp;max-results=25'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>240</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5144379.post-2598381939302467428</id><published>2012-01-31T15:20:00.003Z</published><updated>2012-01-31T15:26:22.437Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='research'/><title type='text'>Paper for EUSAR 2012</title><content type='html'>&lt;p&gt;I'll be presenting a paper in an invited session on urban remote sensing at this year's European Conference on Synthetic Aperture Radar (EUSAR 2012).  The preprint is now available on my website.&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;P.T.B. Brett and R. Guida. Geometry-Based SAR Curvilinear Feature Selection for Damage Detection. In 9th European Conference on Synthetic Aperture Radar - Invited Papers (EUSAR 2012 - Invited Papers), 23-26 April 2011. &lt;a href="http://peter-b.co.uk/downloads/brett_guida_2012.preprint.pdf"&gt;[Preprint]&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;In other news, I will be joining &lt;a href="http://thecostofknowledge.com/"&gt;the boycott of Elsevier and their journals&lt;/a&gt;, and I encourage other researchers to do the same.  Their behaviour is actively damaging to science.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-2598381939302467428?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=2598381939302467428' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/2598381939302467428'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/2598381939302467428'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2012/01/paper-for-eusar-2012.html' title='Paper for EUSAR 2012'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-192125498925523090</id><published>2011-12-28T16:39:00.003Z</published><updated>2011-12-28T19:18:17.948Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='gEDA'/><title type='text'>Coming up to gEDA 1.7.2</title><content type='html'>&lt;p&gt;Later this week, gEDA/gaf 1.7.2 will be released!  Hopefully, this will be the final unstable release before gEDA/gaf 1.8.0, and it will contain a few neat new things that we've been working on over the last six months.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;As I've &lt;a href="http://blog.peter-b.co.uk/2011/06/scheme-api-merge-and-keybinding-in.html"&gt;discussed previously&lt;/a&gt;, this release will incorporate all of the basic Scheme API functionality, to make it easier to write extensions for gschem in pure Scheme.  I've had quite a few e-mails and feature requests from people who have been doing interesting things with the new API, and I'm looking forward to hearing about more tools for enhancing gschem! All of the new functions are documented in the &lt;a href="http://geda.peter-b.co.uk/geda-scheme/"&gt;&lt;i&gt;gEDA Scheme Reference Manual&lt;/i&gt;&lt;/a&gt;.&lt;/li&gt;

&lt;li&gt;In terms of documentation, I've completely re-written the &lt;a href="http://geda.seul.org/wiki/geda:gschem_ug"&gt;&lt;i&gt;gschem User Guide&lt;/i&gt;&lt;/a&gt;, more fully describing many features in gschem that were previously poorly documented, and hopefully making it easier to find the information you need. Gareth Edwards has done a fantastic job of adding man pages to gEDA, and now all of the programs we install have a properly-written man page.&lt;/li&gt;

&lt;li&gt;The first parts of my rework of keymapping will also be included.  Now key names will be properly internationalised when they're displayed, and having Caps Lock enabled will no longer mess up your keybindings.  You can also now bind key combinations that use the Mod, Super or Hyper modifier keys.&lt;/li&gt;

&lt;li&gt;You can now read gEDA documentation on Windows! (About time, really).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What's next once 1.7.2 has been released?  Well, the most important thing is going to be to get a new stable release out.  Many distributions are keen to move to Guile 2.0.x, and the current stable version of gEDA (1.6.2) doesn't support it.  My current hope is to go into a string freeze for gEDA 1.8.0 very soon after gEDA 1.7.2 is released, and aim to get all the translations updated in time for a stable release at the end of January 2012.&lt;/p&gt;

&lt;p&gt;There are many exciting plans for the 1.9.x branch of gEDA, but I'll leave them for another time...&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-192125498925523090?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=192125498925523090' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/192125498925523090'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/192125498925523090'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2011/12/coming-up-to-geda-172.html' title='Coming up to gEDA 1.7.2'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-3188241098751276744</id><published>2011-06-30T22:23:00.004+01:00</published><updated>2011-07-01T10:42:25.249+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gEDA'/><title type='text'>Scheme API merge, and keybinding in gschem</title><content type='html'>&lt;p&gt;Earlier this week I merged the gEDA Scheme API that I've been working on since late 2009 into the main gEDA unstable branch.  It's been a pretty great chunk of work, and I'm glad to have been able to get it into a state where it's generally useful.  It's been pretty fun working out how to answer users' feature requests on gEDA-user with a short Scheme function, too!  Hopefully people will take this new feature and do cool things with it.&lt;/p&gt;

&lt;p&gt;One of the main obstacles to doing cool things with the new Scheme API is that it's difficult to modify key bindings on the fly — gschem doesn't have any equivalent to Emacs' &lt;tt&gt;global-set-key&lt;/tt&gt;, for example.  That makes it hard for e.g. an rc file or Scheme plugin loaded after &lt;tt&gt;system-gschemrc&lt;/tt&gt; to add new keybindings or modify existing ones.  There's also only a single keymap, so there's no possibility for user-modifiable state-specific keymaps (e.g. for binding keys that the user presses while placing a symbol).&lt;/p&gt;

&lt;p&gt;While on the subject of keybindings, the way gschem currently displays keybindings in the menu bar is a little bit rubbish — for example, it would be good to display "]" instead of "bracketright", and "o S" instead of "oShift S".  It's also a shame that we don't support a wider range of modifier keys, including "super" ("⊞" on most keyboards).&lt;/p&gt;

&lt;p&gt;I'm planning to fix all these issues by adding a comprehensive set of Scheme functions for working with keys, key sequences and key bindings to gschem.  Keymaps will probably become a hashtable-based record type, and there will be functions for creating a key sequence from a string and vice versa.  There will also be a function for obtaining a "pretty" string describing a key, suitable for displaying in a menu or in the status line.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-3188241098751276744?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=3188241098751276744' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/3188241098751276744'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/3188241098751276744'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2011/06/scheme-api-merge-and-keybinding-in.html' title='Scheme API merge, and keybinding in gschem'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-6676012164592800985</id><published>2011-06-25T09:26:00.002+01:00</published><updated>2011-06-25T09:59:14.035+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gEDA'/><title type='text'>The gEDA Scheme API manual is here</title><content type='html'>&lt;p&gt;I'm currently working to get my &lt;tt&gt;guile-scheme-api&lt;/tt&gt; branch ready to merge into the main unstable gEDA branch (&lt;tt&gt;master&lt;/tt&gt;).  One of the main jobs that needed to get done before that's possible was to write a reference manual for all of the Scheme functions and variables that the new Scheme API provides, and I've now done that!&lt;/p&gt;

&lt;p&gt;If you're interested in writing extensions for gEDA, please take a look at the draft &lt;a href="http://geda.peter-b.co.uk/geda-scheme/"&gt;&lt;i&gt;gEDA Scheme Reference Manual&lt;/i&gt;&lt;/a&gt; and let me know what you think.  I'm keen to receive any feedback you might have, whether about the manual or about the API itself.&lt;/p&gt;

&lt;p&gt;I'm hoping to merge my work so far in this branch into unstable within the next week.  At the same time, I'm aiming to add the following missing functionality as soon as possible:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Object transformations (translation, rotation and mirroring)&lt;/li&gt;&lt;li&gt;Picture object creation and manipulation&lt;/li&gt;&lt;li&gt;Path object creation and manipulation (quite tricky, unfortunately)&lt;/li&gt;&lt;li&gt;File saving and loading&lt;/li&gt;&lt;li&gt;Picture and component embedding/unembedding
&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;These are all things that I'm sure extension authors would be quite interested in having available to them!  Hopefully we'll see all sorts of interesting new capabilities for gEDA users coming out soon.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-6676012164592800985?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=6676012164592800985' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/6676012164592800985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/6676012164592800985'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2011/06/geda-scheme-api-manual-is-here.html' title='The gEDA Scheme API manual is here'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-5464721280524121443</id><published>2011-06-16T12:23:00.005+01:00</published><updated>2011-06-16T14:13:40.583+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gEDA'/><title type='text'>gEDA and Guile — opportunities to get involved</title><content type='html'>&lt;p&gt;This is the eighth and last in a series of posts on extensibility in gEDA using &lt;a href="http://www.gnu.org/s/guile/"&gt;Guile Scheme&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-finding-scheme-api-code.html"&gt;Finding Scheme API code in gEDA&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-compiling-against.html"&gt;Compiling against multiple Guile versions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-safe-handling-of-non.html"&gt;Safe handling of non-local exits&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-dealing-with-deprecated.html"&gt;Dealing with deprecated &lt;tt&gt;libguile&lt;/tt&gt; functions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-checking-arguments-to.html"&gt;Checking arguments to Scheme functions in C&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-how-and-when-to-use.html"&gt;How and when to use Scheme errors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-reducing-boilerplate.html"&gt;Reducing boilerplate with "snarfing macros"&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Opportunities to get involved&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this post, I'll summarise the series.  In addition, I'll recap on the opportunities to get involved in gEDA development offered by the problems I've identified with the current gEDA codebase.&lt;/p&gt;

&lt;p&gt;In my first and second posts, I described &lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-finding-scheme-api-code.html"&gt;whereabouts in the gEDA codebase to find code which uses Guile&lt;/a&gt;, and also &lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-compiling-against.html"&gt;how to set up a build environment&lt;/a&gt; to easily compile gEDA against either Guile 1.8 or Guile 2.0.  Being able to test with the latest stable release of Guile is quite important, and should definitely be considered by all gEDA developers!&lt;/p&gt;

&lt;p&gt;In my third post, I dealt with probably the most important issue: &lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-safe-handling-of-non.html"&gt;dealing with non-local execution&lt;/a&gt; due to Scheme exceptions and continuations.  There are a lot of places in gEDA where it's assumed that a call to a &lt;tt&gt;libguile&lt;/tt&gt; or Scheme function will return normally, and that's not a safe assumption.  Failing to protect against that (e.g. by using the "dynamic wind" mechanism) can easily result in resources being leaked.&lt;/p&gt;

&lt;p&gt;The following post explained how to get notified when gEDA uses &lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-dealing-with-deprecated.html"&gt;deprecated Guile APIs&lt;/a&gt;. It also gave an example of an instance where using deprecated API long after its deprecation has lead to actual bugs — the &lt;tt&gt;SCM_STRING_CHARS()&lt;/tt&gt; and &lt;tt&gt;SCM_SYMBOL_CHARS()&lt;/tt&gt; macros.&lt;/p&gt;

&lt;p&gt;I went on to talk about the use of Scheme errors.  I described &lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-checking-arguments-to.html"&gt;the use of the &lt;tt&gt;SCM_ASSERT()&lt;/tt&gt; macro to check function arguments&lt;/a&gt;, and also &lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-how-and-when-to-use.html"&gt;how to use Scheme errors more generally&lt;/a&gt;. The main points to remember here were that &lt;tt&gt;libguile&lt;/tt&gt; has some really useful undocumented helper functions for raising Scheme errors from C code (see &lt;tt&gt;libguile/error.h&lt;/tt&gt;), and that just because &lt;tt&gt;SCM_ASSERT()&lt;/tt&gt; has "assert" in its name doesn't mean that you don't have to be careful about resource management if the test fails.&lt;/p&gt;

&lt;p&gt;Finally, I talked about the &lt;tt&gt;guile-snarf&lt;/tt&gt; tool that's used by my &lt;tt&gt;guile-scheme-api&lt;/tt&gt; branch to generate boilerplate code for defining Scheme functions and variables from gEDA's C code.&lt;/p&gt;

&lt;p&gt;There are several opportunities to get involved in making gEDA better.  All these jobs are good for people who aren't that familiar with gEDA development, but who want to get to learn the codebase and about the development process, because they can mostly be done just on a function-by-function basis.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You can help change places where &lt;tt&gt;SCM_STRING_CHARS()&lt;/tt&gt; is still used, to use &lt;tt&gt;scm_to_utf8_string()&lt;/tt&gt; instead.  I've already had some patches from Ivan Stankovic to deal with some of these!&lt;/li&gt;
&lt;li&gt;You can look at the places where gEDA calls into &lt;tt&gt;libguile&lt;/tt&gt; or calls Scheme functions to make sure that any potential errors are handled properly.&lt;/li&gt;
&lt;li&gt;You can double-check that all gEDA functions that take SCM arguments validate them properly using &lt;tt&gt;SCM_ASSERT()&lt;/tt&gt;.&lt;/li&gt;
&lt;li&gt;Or you can help make sure that gEDA Scheme functions raise Scheme errors properly when things go wrong.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're interested in submitting patches addressing any of these, or have any questions, please &lt;a href="mailto:%70%65%74%65%72%40%70%65%74%65%72%2D%62%2E%63%6F%2E%75%6B"&gt;get in touch&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As previously mentioned, my focus for gEDA development in the near future is going to be on getting my &lt;tt&gt;guile-scheme-api&lt;/tt&gt; branch merged, and I encourage everybody to try it out and let me know what you think! For information on my various branches and how to get hold of them, please see my &lt;a href="http://peter-b.co.uk/software/geda.html"&gt;gEDA development page&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-5464721280524121443?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=5464721280524121443' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/5464721280524121443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/5464721280524121443'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2011/06/geda-and-guile-opportunities-to-get.html' title='gEDA and Guile — opportunities to get involved'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-661902960840577200</id><published>2011-06-15T09:33:00.007+01:00</published><updated>2011-06-16T14:20:41.546+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gEDA'/><title type='text'>gEDA and Guile — reducing boilerplate with "snarfing macros"</title><content type='html'>&lt;p&gt;This is the seventh in a series of blog posts on extensibility in gEDA using &lt;a href="http://www.gnu.org/s/guile/"&gt;Guile Scheme&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-finding-scheme-api-code.html"&gt;Finding Scheme API code in gEDA&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-compiling-against.html"&gt;Compiling against multiple Guile versions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-safe-handling-of-non.html"&gt;Safe handling of non-local exits&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-dealing-with-deprecated.html"&gt;Dealing with deprecated &lt;tt&gt;libguile&lt;/tt&gt; functions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-checking-arguments-to.html"&gt;Checking arguments to Scheme functions in C&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-how-and-when-to-use.html"&gt;How and when to use Scheme errors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reducing boilerplate with "snarfing macros"&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-opportunities-to-get.html"&gt;Opportunities to get involved&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this post, I will explain how you can use the &lt;tt&gt;guile-snarf&lt;/tt&gt; tool to reduce the boilerplate needed to define Scheme functions and variables from C.&lt;/p&gt;

&lt;p&gt;At the time of writing, this post isn't really relevant to the main gEDA unstable development branch, since it doesn't currently use "snarfing".  It might be an interesting read if you're interested in hacking on my &lt;tt&gt;guile-scheme-api&lt;/tt&gt; branch.&lt;/p&gt;

&lt;h4&gt;Why is "snarfing" needed?&lt;/h4&gt;

&lt;p&gt;One of the problems with using &lt;tt&gt;libguile&lt;/tt&gt; to define Scheme functions from C is there's a certain amount of boilerplate setup code.  For example, if I wish to define a function called "myfunc" in C to be usable from Scheme, I need to do something like:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
static SCM
my_func (SCM arg)
{
  SCM_ASSERT (scm_is_string (arg), arg, SCM_ARG1, "my-func");

  /* ... do something useful ... */
}

/* Called during application initialisation */
void
my_init ()
{
  scm_c_define_gsubr ("my-func", 1, 0, 0, (SCM (*)()) my_func);
}
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;There are a few problems with this.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If the number of arguments to the function changes, an update needs to be made in two different places.&lt;/li&gt;
&lt;li&gt;If the string name of the function changes ("myfunc" in this case), an update needs to be made in two places, and also to every other place the name is used (e.g. &lt;tt&gt;SCM_ASSERT()&lt;/tt&gt; for arguments and any other place a Scheme error is raised).&lt;/li&gt;
&lt;li&gt;If an extra function is added...&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You get the idea.&lt;/p&gt;
&lt;p&gt;Similarly, if there is a permanent Scheme value that's needed in multiple functions (such as a symbol) it's necessary to separately define the static variable and add a line to the initialisation function.&lt;/p&gt;
&lt;p&gt;Finally, if the &lt;tt&gt;libguile&lt;/tt&gt; API for defining a function or variable changes, it's necessary to individually update the initialisation code for every single one.&lt;/p&gt;

&lt;h4&gt;The &lt;tt&gt;guile-snarf&lt;/tt&gt; tool&lt;/h4&gt;

&lt;p&gt;Guile comes with a tool called &lt;a href="http://www.gnu.org/software/guile/manual/html_node/Function-Snarfing.html#Function-Snarfing"&gt;&lt;tt&gt;guile-snarf&lt;/tt&gt;&lt;/a&gt;, which is run against a C source file to generate an additional C source file for inclusion, usually given a &lt;tt&gt;.x&lt;/tt&gt; extension.&lt;/p&gt;

&lt;p&gt;The tool recognises some special macros in the C source, which expand normally when compiled, but which are used by the tool to generate Scheme initialisation boilerplate. The example above would become:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
SCM_DEFINE (my_func,   /* Function name in C */
            "my-func", /* Function name in Scheme */
            1, 0,      /* No. of required/optional args */
            0,         /* Whether accepts "rest" arg */
            (SCM arg), /* C argument list */
            "Do something exciting.") /* Docstring */
{
  SCM_ASSERT (scm_is_string (arg), arg, SCM_ARG1, s_my_func);

  /* ... do something useful ... */
}

/* Called during application initialisation */
void
my_init ()
{
  #include "mycfile.x";
}
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;This may seem like a small gain for this trivial example, but for files which define a large number of Scheme procedures there's a definite benefit! There are a few things to note:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Functions defined using &lt;tt&gt;SCM_DEFINE()&lt;/tt&gt; are always static.  This shouldn't normally be a problem, since they will usually be intended to be called from Scheme, not from other C functions.&lt;/li&gt;
&lt;li&gt;For each function &lt;tt&gt;foo&lt;/tt&gt;, &lt;tt&gt;SCM_DEFINE()&lt;/tt&gt; also defines a static string called &lt;tt&gt;s_foo&lt;/tt&gt;.  This can be pretty handy, especially when needing to pass the Scheme name of the function to &lt;tt&gt;SCM_ASSERT()&lt;/tt&gt; macros. (Its use is discouraged by the official documentation, but &lt;tt&gt;libguile&lt;/tt&gt; itself makes use of it, so hey — it can't be that much of a problem!)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Although &lt;tt&gt;SCM_DEFINE&lt;/tt&gt; is the main reason to use &lt;tt&gt;guile-snarf&lt;/tt&gt;, there are &lt;a href="http://www.gnu.org/software/guile/manual/html_node/Snarfing-Macros.html#Snarfing-Macros"&gt;several other really useful macros&lt;/a&gt;, such as &lt;tt&gt;SCM_SYMBOL("foo")&lt;/tt&gt;, which creates &amp; defines a variable containing the symbol "foo".  In my &lt;tt&gt;guile-scheme-api&lt;/tt&gt; branch, you will fairly commonly see a block at the top of a C source file looking like:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
SCM_SYMBOL (lower_left_sym , "lower-left");
SCM_SYMBOL (middle_left_sym , "middle-left");
SCM_SYMBOL (upper_left_sym , "upper-left");
SCM_SYMBOL (lower_center_sym , "lower-center");
SCM_SYMBOL (middle_center_sym , "middle-center");
SCM_SYMBOL (upper_center_sym , "upper-center");
SCM_SYMBOL (lower_right_sym , "lower-right");
SCM_SYMBOL (middle_right_sym , "middle-right");
SCM_SYMBOL (upper_right_sym , "upper-right");
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;This then allows functions in the file to use the symbols to construct Scheme expressions to be evaluated without needing to recreate the symbols (e.g. using &lt;tt&gt;scm_from_utf8_symbol()&lt;/tt&gt;) every time the function is run.&lt;/p&gt;

&lt;h4&gt;Conclusion&lt;/h4&gt;

&lt;p&gt;Currently, when wishing to alter the prototype a Scheme function provided by a gEDA program, you need to make changes in at least three places:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The function definition itself.&lt;/li&gt;
&lt;li&gt;The function prototype in a header file.&lt;/li&gt;
&lt;li&gt;The function metadata exported to Scheme, usually in a file called &lt;tt&gt;g_register.c&lt;/tt&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Using the &lt;tt&gt;SCM_DEFINE()&lt;/tt&gt; "snarfing" macro and the &lt;tt&gt;guile-snarf&lt;/tt&gt; tool would allow two of those places to be eliminated, and that's why my &lt;tt&gt;guile-scheme-api&lt;/tt&gt; branch uses them.&lt;/p&gt;

&lt;p&gt;The next and final post in this series will summarise the things I've written about, and give a list of easy introductory gEDA development tasks based on some of the issues I've raised.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-661902960840577200?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=661902960840577200' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/661902960840577200'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/661902960840577200'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2011/06/geda-and-guile-reducing-boilerplate.html' title='gEDA and Guile — reducing boilerplate with &quot;snarfing macros&quot;'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-8392078338688497444</id><published>2011-06-13T11:45:00.004+01:00</published><updated>2011-06-16T14:19:58.414+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gEDA'/><title type='text'>gEDA and Guile — how and when to use Scheme errors</title><content type='html'>&lt;p&gt;This is the sixth in a series of blog posts on extensibility in gEDA using &lt;a href="http://www.gnu.org/s/guile/"&gt;Guile Scheme&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-finding-scheme-api-code.html"&gt;Finding Scheme API code in gEDA&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-compiling-against.html"&gt;Compiling against multiple Guile versions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-safe-handling-of-non.html"&gt;Safe handling of non-local exits&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-dealing-with-deprecated.html"&gt;Dealing with deprecated &lt;tt&gt;libguile&lt;/tt&gt; functions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-checking-arguments-to.html"&gt;Checking arguments to Scheme functions in C&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How and when to use Scheme errors&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-reducing-boilerplate.html"&gt;Reducing boilerplate with "snarfing macros"&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-opportunities-to-get.html"&gt;Opportunities to get involved&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this post, I will try to make it clear how and when to raise Scheme errors in procedures implemented in C.&lt;/p&gt;

&lt;p&gt;As explained in an earlier blog post in this series, Guile has a fully-fledged exception mechanism, which is used as the basis for its error reporting system.  Because this allows execution to jump non-locally when an error occurs, &lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-safe-handling-of-non.html"&gt;it requires resources to be carefully managed&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Other than &lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-checking-arguments-to.html"&gt;checking types using the &lt;tt&gt;SCM_ASSERT()&lt;/tt&gt; macro&lt;/a&gt;, when else might it be useful to raise Scheme errors from C functions in gEDA?&lt;/p&gt;

&lt;h4&gt;When to raise Scheme errors&lt;/h4&gt;

&lt;p&gt;In Scheme functions written in Scheme, the answer is obvious: raise a Scheme error using &lt;tt&gt;error&lt;/tt&gt; or &lt;tt&gt;scm-error&lt;/tt&gt;.  In C, it's not so simple.&lt;/p&gt;

&lt;p&gt;Recall that there are currently four approaches to error handling in gEDA's C source code:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Give up (log an error message and quit immediately).&lt;/li&gt;
&lt;li&gt;The &lt;a href="http://developer.gnome.org/glib/stable/glib-Error-Reporting.html"&gt;&lt;tt&gt;GError&lt;/tt&gt;&lt;/a&gt; mechanism from GLib.&lt;/li&gt;
&lt;li&gt;Best-effort (log an warning message and return a default value).&lt;/li&gt;
&lt;li&gt;Raise a Scheme error.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We try and avoid the "giving up" option, because quite often the situation is not actually hopeless, and the error could be handled by a function further up the stack or at the very least the user might be able to save his or her data.&lt;/p&gt;

&lt;p&gt;In functions that are actual C API (i.e. designed primarily to be called by other C functions), Scheme errors are never appropriate, because they're quite complex to catch and handle in C. It's much easier to get from a &lt;tt&gt;GError&lt;/tt&gt; to a Scheme error than the other way round!  These sorts of functions should either use &lt;tt&gt;GError&lt;/tt&gt; (for run-time errors outside the developers' control, such as being asked to load a file that doesn't exist), or use a "best-effort" approach (for programming errors, e.g. return &lt;tt&gt;NULL&lt;/tt&gt; when asked for a list of objects in a &lt;tt&gt;NULL&lt;/tt&gt; page).&lt;/p&gt;

&lt;p&gt;On the other hand, functions that are designed primarily to be called from Scheme code should &lt;em&gt;exclusively&lt;/em&gt; use Scheme errors.  If there's a problem, either it'll be caught and handled, or it won't and an error message will be generated (and the program may exit).&lt;/p&gt;

&lt;p&gt;This means that you shouldn't use best-effort helper macros like &lt;a href="http://developer.gnome.org/glib/stable/glib-Warnings-and-Assertions.html#g-return-if-fail"&gt;&lt;tt&gt;g_return_if_fail()&lt;/tt&gt;&lt;/a&gt; — if you're called with invalid arguments, generate a Scheme error (e.g. using &lt;tt&gt;SCM_ASSERT()&lt;/tt&gt;). You can apply a simple rule of thumb: if the &lt;tt&gt;SCM&lt;/tt&gt; type appears in the function prototype, you should normally use Scheme error reporting.&lt;/p&gt;

&lt;h4&gt;How to raise Scheme errors&lt;/h4&gt;

&lt;p&gt;With &lt;tt&gt;libguile&lt;/tt&gt;, the main function to use to raise Scheme errors is &lt;a href="http://www.gnu.org/software/guile/manual/html_node/Error-Reporting.html#Error-Reporting"&gt;&lt;tt&gt;scm_error_scm()&lt;/tt&gt;&lt;/a&gt;. However, the &lt;tt&gt;libguile&lt;/tt&gt; headers provide some additional &lt;em&gt;undocumented&lt;/em&gt; helper functions which make raising errors from C functions &lt;em&gt;much more convenient&lt;/em&gt;. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;tt&gt;scm_error()&lt;/tt&gt; is similar to &lt;tt&gt;scm_error_scm()&lt;/tt&gt; but allows you to pass the raising function's name as a &lt;tt&gt;char *&lt;/tt&gt; string rather than a Scheme string.&lt;/tt&gt; &lt;/li&gt;
&lt;li&gt;&lt;tt&gt;scm_misc_error()&lt;/tt&gt; is the easiest way to generate errors for which it's not worth assigning a specific error key, and is the C equivalent to the &lt;tt&gt;error&lt;/tt&gt; function in Scheme.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A full list of functions for raise errors is available in &lt;tt&gt;libguile/error.h&lt;/tt&gt;, and since they are much better than &lt;tt&gt;scm_error_scm()&lt;/tt&gt;, &lt;em&gt;use them&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Don't forget that raising a Scheme error causes a non-local exit, and make provisions (such as using dynamic wind) to release any resources you hold correctly.&lt;/p&gt;

&lt;h4&gt;Conclusion&lt;/h4&gt;

&lt;p&gt;Guile provides a full-featured error-reporting system, which gEDA applications should use in their Scheme APIs more than they currently do.  The best way to raise a Scheme error isn't via &lt;tt&gt;scm_error_scm()&lt;/tt&gt;, but through the undocumented helper functions that &lt;tt&gt;libguile&lt;/tt&gt; provides (and I should probably submit a documentation patch to upstream Guile to fix that...)&lt;/p&gt;

&lt;p&gt;In my next post, I'll talk about the &lt;tt&gt;guile-snarf&lt;/tt&gt; tool, and how to use Guile's "snarfing macros" to simplify the boilerplate needed to export C functions as callable from Scheme.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-8392078338688497444?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=8392078338688497444' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/8392078338688497444'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/8392078338688497444'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2011/06/geda-and-guile-how-and-when-to-use.html' title='gEDA and Guile — how and when to use Scheme errors'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-2718790607308894223</id><published>2011-06-12T09:51:00.006+01:00</published><updated>2011-06-16T14:18:41.526+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gEDA'/><title type='text'>gEDA and Guile — checking arguments to Scheme functions in C</title><content type='html'>&lt;p&gt;This is the fifth in a series of blog posts on extensibility in gEDA using &lt;a href="http://www.gnu.org/s/guile/"&gt;Guile Scheme&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-finding-scheme-api-code.html"&gt;Finding Scheme API code in gEDA&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-compiling-against.html"&gt;Compiling against multiple Guile versions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-safe-handling-of-non.html"&gt;Safe handling of non-local exits&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-dealing-with-deprecated.html"&gt;Dealing with deprecated &lt;tt&gt;libguile&lt;/tt&gt; functions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Checking arguments to Scheme functions in C&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-how-and-when-to-use.html"&gt;How and when to use Scheme errors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-reducing-boilerplate.html"&gt;Reducing boilerplate with "snarfing macros"&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-opportunities-to-get.html"&gt;Opportunities to get involved&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this post I'll explain how to use the  &lt;a href="http://www.gnu.org/software/guile/manual/html_node/Handling-Errors.html#index-SCM_005fASSERT-2050"&gt;&lt;tt&gt;SCM_ASSERT()&lt;/tt&gt;&lt;/a&gt; macro to check arguments passed to Guile functions written in C using &lt;tt&gt;libguile&lt;/tt&gt;.&lt;/p&gt;

&lt;h4&gt;Using &lt;tt&gt;SCM_ASSERT()&lt;/tt&gt;&lt;/h4&gt;

&lt;p&gt;&lt;tt&gt;SCM_ASSERT()&lt;/tt&gt; is a shorthand way to raise a Scheme &lt;tt&gt;wrong-type-arg&lt;/tt&gt; error for a Scheme variable if a test fails.  For example, if there is a function which takes a string as an argument, you might write it as:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
SCM
myfunc (SCM str)
{
  SCM_ASSERT (scm_is_string (str), str, SCM_ARG1, "my-func");

  /* ... do things with str ... */
}
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;All functions in gEDA which are exposed as Scheme procedures &lt;em&gt;must&lt;/em&gt; use &lt;tt&gt;SCM_ASSERT()&lt;/tt&gt; to thoroughly check the types of their arguments.&lt;/p&gt;

&lt;p&gt;There are a few things to note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first parameter to &lt;tt&gt;SCM_ASSERT()&lt;/tt&gt; is a test, and should evaluate to an integer, &lt;em&gt;not&lt;/em&gt; a Scheme value. If the test is zero, an error is signalled.&lt;/li&gt;
&lt;li&gt;If you need to use a test which evaluates to a Scheme value (e.g. &lt;tt&gt;scm_list_p()&lt;/tt&gt;), don't compare it to &lt;tt&gt;SCM_BOOL_F&lt;/tt&gt; or &lt;tt&gt;SCM_BOOL_T&lt;/tt&gt; directly; use &lt;tt&gt;scm_is_true()&lt;/tt&gt; or &lt;tt&gt;scm_is_false()&lt;/tt&gt;.&lt;/li&gt;
&lt;li&gt;The second parameter is the variable which has the wrong type.  Although the test might not be on it directly (e.g. if you are checking for a list of strings), the second parameter must always be the actual argument which was passed to &lt;tt&gt;myfunc&lt;/tt&gt;.&lt;/li&gt;
&lt;li&gt;The third parameter to &lt;tt&gt;SCM_ASSERT()&lt;/tt&gt; indicates which argument to &lt;tt&gt;myfunc&lt;/tt&gt; had the wrong type — and remember that this is 1-indexed. Although this parameter is just an integer, you should always use the &lt;tt&gt;SCM_ARG1&lt;/tt&gt;, &lt;tt&gt;SCM_ARG2&lt;/tt&gt; etc. macros for arguments up to 7, since this makes the purpose of the parameter more readable.&lt;/li&gt;
&lt;li&gt;If you have a function that takes an arbitrary number of parameters, you should use the &lt;tt&gt;SCM_ARGn&lt;/tt&gt; macro as the argument index.&lt;/li&gt;
&lt;li&gt;The final parameter is a &lt;tt&gt;char *&lt;/tt&gt; string containing the name of the function &lt;em&gt;as seen by Scheme&lt;/em&gt; (&lt;tt&gt;"my-func"&lt;/tt&gt; in this case).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have a C helper function which is used by many similar Scheme functions, you can generate more useful error messages if you pass it the name of the function that's actually visible to Scheme code.  For example:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
void
helperfunc (SCM str, const char *funcname)
{
  SCM_ASSERT (scm_is_string (str), str, SCM_ARGn, funcname);

  /* ... do things ... */
}

void
myfunc (SCM str)
{
  helperfunc (str, "my-func");

  /* ... do more things ... */
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h4&gt;Don't leak resources!&lt;/h4&gt;

&lt;p&gt;The most important thing to remember is that &lt;tt&gt;SCM_ASSERT()&lt;/tt&gt; &lt;em&gt;does not&lt;/em&gt; behave like most normal assertion mechanisms when programming in C (&lt;a href="http://developer.gnome.org/glib/stable/glib-Testing.html#g-assert"&gt;&lt;tt&gt;g_assert()&lt;/tt&gt;&lt;/a&gt; in GLib for example), in that it &lt;em&gt;doesn't end the program if it fails&lt;/em&gt; — it simply causes a non-local exit by raising an error.&lt;/p&gt;

&lt;p&gt;Because &lt;tt&gt;SCM_ASSERT()&lt;/tt&gt; might not return, it's really important to be careful about managing resources when writing a Scheme function in C. For example, consider a function that needs to convert a Scheme list of strings into a &lt;tt&gt;GList&lt;/tt&gt; of C strings.  Here's a naive, broken implementation:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
/* Don't do this -- it leaks memory */
void
process_string_list (SCM lst)
{
  GList *glst = NULL;
  SCM_ASSERT (scm_is_true (scm_list_p (lst))), lst, SCM_ARG1,
              "process-string-list");

  for (SCM iter = lst; iter != SCM_EOL; iter = SCM_CDR (iter)) {
    SCM str = SCM_CAR (iter);
    SCM_ASSERT (scm_is_string (str)), lst, SCM_ARG1, "process-string-list");
    glst = g_list_prepend (glst, scm_to_utf8_string (str));
  }

  /* ... do something with glst ... */
}
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;If the &lt;tt&gt;SCM_ASSERT()&lt;/tt&gt; inside the loop raises an error, the stack will unwind out of &lt;tt&gt;process_string_list()&lt;/tt&gt; and the memory allocated in &lt;tt&gt;glst&lt;/tt&gt; will be leaked.  Instead, you could check the input, and then build the list:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
void
process_string_list (SCM lst)
{
  GList *glst = NULL;
  SCM_ASSERT (scm_is_true (scm_list_p (lst))), lst, SCM_ARG1,
              "process-string-list");

  /* Check the input is actually a list of strings */
  for (SCM iter = lst; iter != SCM_EOL; iter = SCM_CDR (iter)) {
    SCM_ASSERT (scm_is_string (SCM_CAR (iter)), lst, SCM_ARG1, "process-string-list");
  }

  /* Convert to a GList */
  for (SCM iter = lst; iter != SCM_EOL; iter = SCM_CDR (lst)) {
    glst = g_list_prepend (glst, scm_to_utf8_string (SCM_CAR (iter)));
  }

  /* ... do something with glst ... */
}
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;The problem with this is that it is inefficient, as it requires iterating over the linked list twice.  A more efficient approach would be to use dynamic wind, as I discussed in &lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-safe-handling-of-non.html"&gt;a previous post in this series&lt;/a&gt;.&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
/* A function for freeing a GList containing strings */
static void
free_string_glist (void *data)
{
  GList *glst = *((GList *) data);
  for (GList *iter = glst; iter != NULL; iter = g_list_next (iter)) {
    free (iter-&gt;data);
  }
  g_list_free (glst);
}

void
process_string_list (SCM lst)
{
  GList *glst = NULL;
  SCM_ASSERT (scm_is_true (scm_list_p (lst))), lst, SCM_ARG1,
              "process-string-list");

  /* Begin a dynamic extent, and register a handler to clean up on error */
  scm_dynwind_begin (0);
  scm_dynwind_unwind_handler (free_string_glist, (void *) &amp;glst, 0);

  /* Convert to a GList, checking types */
  for (SCM iter = lst; iter != SCM_EOL; iter = SCM_CDR (iter)) {
    SCM str = SCM_CAR (iter);
    SCM_ASSERT (scm_is_string (str)), lst, SCM_ARG1, "process-string-list");
    glst = g_list_prepend (glst, scm_to_utf8_string (str));
  }

  /* End dynamic extent */
  scm_dynwind_end ();

  /* ... do something with glst ... */
}
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: Thanks to Ivan Stankovic for pointing out a bug in this example!&lt;/p&gt;

&lt;p&gt;Unfortunately, there appear to be quite a few places in gEDA where there is the potential for resource leakage like this to occur, and checking that all functions which use &lt;tt&gt;SCM_ASSERT()&lt;/tt&gt; do so in a safe manner would be a really useful thing to do.&lt;/p&gt;

&lt;h4&gt;Conclusion&lt;/h4&gt;

&lt;p&gt;As you can tell, even doing something as conceptually simple as checking your arguments safely can be a tricky thing to get right when using &lt;tt&gt;libguile&lt;/tt&gt; — another argument, if you needed one, for keeping the number of functions in gEDA's Scheme API as small as possible while still exposing all of the necessary functionality.&lt;/p&gt;

&lt;p&gt;In my next post, I'll discuss how (and when!) in general to throw Scheme errors from C.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-2718790607308894223?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=2718790607308894223' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/2718790607308894223'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/2718790607308894223'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2011/06/geda-and-guile-checking-arguments-to.html' title='gEDA and Guile — checking arguments to Scheme functions in C'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-5117679173246988267</id><published>2011-06-11T09:04:00.009+01:00</published><updated>2011-06-16T14:19:14.911+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gEDA'/><title type='text'>gEDA and Guile — dealing with deprecated libguile functions</title><content type='html'>&lt;p&gt;This is the fourth in a series of blog posts on extensibility in gEDA using &lt;a href="http://www.gnu.org/s/guile/"&gt;Guile Scheme&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-finding-scheme-api-code.html"&gt;Finding Scheme API code in gEDA&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-compiling-against.html"&gt;Compiling against multiple Guile versions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-safe-handling-of-non.html"&gt;Safe handling of non-local exits&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dealing with deprecated &lt;tt&gt;libguile&lt;/tt&gt; functions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-checking-arguments-to.html"&gt;Checking arguments to Scheme functions in C&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-how-and-when-to-use.html"&gt;How and when to use Scheme errors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-reducing-boilerplate.html"&gt;Reducing boilerplate with "snarfing macros"&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-opportunities-to-get.html"&gt;Opportunities to get involved&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this post I'll explain how to set up your environment to get warnings about use of deprecated &lt;tt&gt;libguile&lt;/tt&gt; API, and some of the most problematic deprecated API usage in gEDA.&lt;/p&gt;

&lt;h4&gt;Getting notified about deprecated API usage&lt;/h4&gt;

&lt;p&gt;Most gEDA applications use something like the following to disable deprecation warnings unless you specifically set your environment to request them:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
if (getenv ("GUILE_WARN_DEPRECATED") == NULL)
  putenv ("GUILE_WARN_DEPRECATED=no");
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;The simplest way to enable deprecation warnings is, therefore, to add something like this to your shell rc file:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
GUILE_WARN_DEPRECATED="detailed"
export GUILE_WARN_DEPRECATED
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;Now when you start &lt;tt&gt;gschem&lt;/tt&gt;, you'll get a few warnings on stderr (depending on which version of Guile you've compiled against). Here's an example of what you see when starting &lt;tt&gt;gschem&lt;/tt&gt; if you compile against Guile 2.0:&lt;/p&gt;

&lt;code&gt;$ gschem&lt;br/&gt;
`(debug-enable 'debug)' is obsolete and has no effect. &lt;strong style="color:red;"&gt;(1)&lt;/strong&gt;&lt;br/&gt;
Remove it from your code.&lt;br/&gt;
SCM_STRING_CHARS is deprecated.  See the manual for alternatives. &lt;strong style="color:red;"&gt;(2)&lt;/strong&gt;&lt;br/&gt;
SCM_SYMBOL_CHARS is deprecated.  Use scm_symbol_to_string. &lt;strong style="color:red;"&gt;(3)&lt;/strong&gt;&lt;br/&gt;
&lt;/code&gt;

&lt;p&gt;Some of this is a problem, some of it isn't.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;We use &lt;tt&gt;(debug-enable 'debug)&lt;/tt&gt; in &lt;tt&gt;system-gafrc&lt;/tt&gt; to enable backtraces in Guile 1.8, but it does nothing in Guile 2.0.  It would be nice to find a way to only call it if necessary, but it's not really a priority.&lt;/li&gt;
&lt;li&gt;&lt;tt&gt;SCM_STRING_CHARS()&lt;/tt&gt; is used &lt;em&gt;a lot&lt;/em&gt; in gEDA to obtain a pointer to the underlying character buffer of a Scheme string, and it's been deprecated since Guile 1.8.0. gEDA's reliance on this is a bit of a problem, unfortunately, and I'll explain why later.&lt;/li&gt;
&lt;li&gt;&lt;tt&gt;SCM_SYMBOL_CHARS()&lt;/tt&gt; is similar to &lt;tt&gt;SCM_STRING_CHARS()&lt;/tt&gt; (but for the string representation of a Scheme symbol), and has also been deprecated for a long time.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;The problem with &lt;tt&gt;SCM_STRING_CHARS()&lt;/tt&gt; and &lt;tt&gt;SCM_SYMBOL_CHARS()&lt;/tt&gt;&lt;/h4&gt;

&lt;p&gt;So, why is using &lt;tt&gt;SCM_STRING_CHARS()&lt;/tt&gt; a problem? The main issue is that its use assumes that Guile's internal string representation is the same as gEDA's, i.e. an array of &lt;tt&gt;char&lt;/tt&gt;, and that Guile's internal string encoding is the same as gEDA's, i.e. UTF-8.  &lt;strong&gt;Neither of these assumptions are reliable.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are two different internal representations for strings in Guile 2.0. All strings are stored as an array of Unicode code points.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If all the code points are in the range 0-255 inclusive, the code points are stored with one byte per code point, i.e. as Latin-1 or ISO-9959-1.  This is not UTF-8.&lt;/li&gt;
&lt;li&gt;If any of the code points is outside that range, &lt;em&gt;the whole string&lt;/em&gt; is stored with four bytes per code point, i.e. as UTF-32. This is also not UTF-8.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Additionally, Guile 2.0 introduces read-only strings (which don't work with &lt;tt&gt;SCM_STRING_CHARS()&lt;/tt&gt;) and shared substrings (which don't work with &lt;tt&gt;SCM_STRING_CHARS()&lt;/tt&gt;).&lt;/p&gt;

&lt;p&gt;So how can we break a function &lt;tt&gt;func&lt;/tt&gt; that takes a single string argument and uses &lt;tt&gt;SCM_STRING_CHARS()&lt;/tt&gt;? Let me count the ways.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;We can pass it a string containing code points above 255. Since we target a worldwide user base these days, that's not particularly unlikely.&lt;/p&gt;
&lt;code&gt;&lt;pre&gt;(func "你好")&lt;/pre&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We can pass it a shared substring.&lt;/p&gt;
&lt;code&gt;&lt;pre&gt;(func (substring/shared "foo bar" 0 3))&lt;/pre&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We can pass it a read-only substring&lt;/p&gt;
&lt;code&gt;&lt;pre&gt;(func (substring/read-only "foo bar" 0 3))&lt;/pre&gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;tt&gt;SCM_SYMBOL_CHARS()&lt;/tt&gt; shares all these problems.  Both these macros have been deprecated since Guile 1.8.0 exactly because the Guile developers wanted to be able to change Guile's original internal string representation to support Unicode fully.  (In case you're wondering why they don't use UTF-8, it's because Scheme requires a bunch of string operators that operate on the nth character in a string, and using UTF-8 would make those operators much slower).&lt;/p&gt;

&lt;h4&gt;Replacing &lt;tt&gt;SCM_STRING_CHARS()&lt;/tt&gt;&lt;/h4&gt;

&lt;p&gt;What's the alternative?  Ideally, we'd use the rather handy &lt;a href="http://www.gnu.org/software/guile/manual/html_node/Conversion-to_002ffrom-C.html#index-g_t_002ascm_005fto_005futf8_005fstringn-954"&gt;&lt;tt&gt;scm_to_utf8_stringn()&lt;/tt&gt;&lt;/a&gt; function, but that was only introduced in Guile 2.0 (along with Unicode support), so it's not an option.  Instead, we have to rely on &lt;a href="http://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Conversion-to_002ffrom-C.html#index-scm_005fto_005flocale_005fstring-850"&gt;&lt;tt&gt;scm_to_locale_string()&lt;/tt&gt;&lt;/a&gt;. The main difference between the new functions and &lt;tt&gt;SCM_STRING_CHARS()&lt;/tt&gt; is that the new functions allocate memory, which must be freed with &lt;tt&gt;free()&lt;/tt&gt; (n.b. &lt;em&gt;not&lt;/em&gt; &lt;tt&gt;g_free()&lt;/tt&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: gEDA now provides &lt;tt&gt;scm_to_utf8_string()&lt;/tt&gt; and &lt;tt&gt;scm_from_utf8_string()&lt;/tt&gt; even if Guile doesn't, so always use them unless you actually want to work with locale-encoded strings.&lt;/p&gt;

&lt;p&gt;So suppose we started off with a version of &lt;tt&gt;myfunc()&lt;/tt&gt; that uses &lt;tt&gt;SCM_STRING_CHARS()&lt;/tt&gt;:&lt;/p&gt;
&lt;code&gt;&lt;pre&gt;
void
myfunc (SCM arg)
{
  /* N.b. we should check that arg is in fact a string */
  printf ("%s", SCM_STRING_CHARS (arg));
}
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;It should be replaced by:&lt;/p&gt;
&lt;code&gt;&lt;pre&gt;
void
myfunc (SCM arg)
{
  char *arg_str;
  /* N.b. we should check that arg is in fact a string */
  arg_str = scm_to_utf8_string (arg);
  printf ("%s", arg_str);
  free (arg_str);
}
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;In reality, you'll want to do something more complicated than just print the string. Don't forget that if you do more than trivial calls into &lt;tt&gt;libguile&lt;/tt&gt; in between creating &lt;tt&gt;arg_str&lt;/tt&gt; and freeing it you should probably &lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-safe-handling-of-non.html"&gt;use dynamic wind&lt;/a&gt; to make sure that it is properly cleaned up.&lt;/p&gt;
&lt;p&gt;You should also be aware that because &lt;tt&gt;scm_to_utf8_string()&lt;/tt&gt; tries to return a null-terminated string, it throws an error if the string contains &lt;tt&gt;#\nul&lt;/tt&gt; characters. It can throw an error if the string can't be converted to the requested encoding (which is locale-dependent for &lt;tt&gt;scm_to_locale_string()&lt;/tt&gt;). This introduces its own challenges.&lt;/p&gt;

&lt;h4&gt;Replacing &lt;tt&gt;SCM_SYMBOL_CHARS()&lt;/tt&gt;&lt;/h4&gt;

&lt;p&gt;Replacing &lt;tt&gt;SCM_SYMBOL_CHARS()&lt;/tt&gt; is similar to replacing &lt;tt&gt;SCM_STRING_CHARS()&lt;/tt&gt;; simply use &lt;tt&gt;scm_symbol_to_string()&lt;/tt&gt; to convert the symbol to a string, and then use &lt;tt&gt;scm_to_utf8_string()&lt;/tt&gt; as before.&lt;/p&gt;

&lt;h4&gt;Conclusion&lt;/h4&gt;

&lt;p&gt;Library APIs are rarely deprecated without a good reason, and being aware of and proactive about updating deprecated API usage can help avoid some serious problems.  Updating gEDA to remove the use of the &lt;tt&gt;SCM_STRING_CHARS()&lt;/tt&gt; and &lt;tt&gt;SCM_SYMBOL_CHARS()&lt;/tt&gt; macros is an important job. Nevertheless, it would still be quite accessible for someone less familiar with the gEDA code base, as it can be done by dealing with one function at a time.&lt;/p&gt;

&lt;p&gt;In my next post, I will describe how to use &lt;tt&gt;SCM_ASSERT&lt;/tt&gt; to check types of &lt;tt&gt;SCM&lt;/tt&gt; arguments to functions that use &lt;tt&gt;libguile&lt;/tt&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-5117679173246988267?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=5117679173246988267' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/5117679173246988267'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/5117679173246988267'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2011/06/geda-and-guile-dealing-with-deprecated.html' title='gEDA and Guile — dealing with deprecated libguile functions'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-6314681632686863801</id><published>2011-06-10T11:07:00.009+01:00</published><updated>2011-06-16T14:17:26.673+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gEDA'/><title type='text'>gEDA and Guile — safe handling of non-local exits</title><content type='html'>&lt;p&gt;This is the third in a series of blog posts on extensibility in gEDA using &lt;a href="http://www.gnu.org/s/guile/"&gt;Guile Scheme&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-finding-scheme-api-code.html"&gt;Finding Scheme API code in gEDA&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-compiling-against.html"&gt;Compiling against multiple Guile versions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Safe handling of non-local exits&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-dealing-with-deprecated.html"&gt;Dealing with deprecated &lt;tt&gt;libguile&lt;/tt&gt; functions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-checking-arguments-to.html"&gt;Checking arguments to Scheme functions in C&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-how-and-when-to-use.html"&gt;How and when to use Scheme errors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-reducing-boilerplate.html"&gt;Reducing boilerplate with "snarfing macros"&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-opportunities-to-get.html"&gt;Opportunities to get involved&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this post I'll be talking about an issue which the current gEDA codebase doesn't deal with very well: dealing with non-local exits in C code that uses &lt;tt&gt;libguile&lt;/tt&gt;.&lt;/p&gt;

&lt;h4&gt;What are non-local exits?&lt;/h4&gt;

&lt;p&gt;Non-local exits are a way for execution to jump out of the current execution context to another point in the program. The only way of doing this in C is through the quite limited &lt;tt&gt;setjmp&lt;/tt&gt;/&lt;tt&gt;longjmp&lt;/tt&gt; mechanism .Guile supports two fully-featured constructs for non-local control flow: &lt;strong&gt;exceptions&lt;/strong&gt; and &lt;strong&gt;continuations&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Exceptions will be fairly familiar to many developers, as they are heavily used in languages such as Java and Python. When an exception is thrown, the stack is unwound until an &lt;strong&gt;exception handler&lt;/strong&gt; is found for the exception. If none is found, then the program will usually exit with an uncaught exception error. Guile uses exceptions to implement its error handling mechanism, and you can read about that in more detail in the Guile manual (&lt;a href="http://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Exceptions.html#Exceptions"&gt;Exceptions&lt;/a&gt;, &lt;a href="http://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Error-Reporting.html#Error-Reporting"&gt;Error Reporting&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;The other way that a non-local exit might occur is via a &lt;a href="http://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Continuations.html#Continuations"&gt;continuation&lt;/a&gt;. These are pretty hard to get your head around, unfortunately. The Guile manual describes them as follows:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;A “continuation” is the code that will execute when a given function or expression returns. For example, consider&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
(define (foo)
  (display "hello\n")
  (display (bar)) (newline)
  (exit))
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;The continuation from the call to bar comprises a display of the value returned, a newline and an exit. This can be expressed as a function of one argument.&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
(lambda (r)
  (display r) (newline)
  (exit))
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;In Scheme, continuations are represented as special procedures just like this. The special property is that when a continuation is called it abandons the current program location and jumps directly to that represented by the continuation.&lt;/p&gt;

&lt;p&gt;A continuation is like a dynamic label, capturing at run-time a point in program execution, including all the nested calls that have lead to it (or rather the code that will execute when those calls return).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guile implements continuations that are usable from C code with some pretty crazy techniques for saving and restoring the C stack.&lt;/p&gt;
&lt;p&gt;The important point to take away from this is that &lt;strong&gt;when you call a Scheme function from C, you cannot depend on it returning normally&lt;/strong&gt;. That means that totally legitimate resource management in a normal C/GLib program, such as:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
void myfunc()
{
  gchar *buf = g_strdup ("const string");
  anotherfunc (buf);
  g_free (buf);
}
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;becomes unsafe if &lt;tt&gt;anotherfunc()&lt;/tt&gt; calls Scheme code that might either call a continuation or throw an exception, since in that case the call to &lt;tt&gt;g_free()&lt;/tt&gt; would never occur and the memory assigned to &lt;tt&gt;buf&lt;/tt&gt; will be leaked.&lt;/p&gt;

&lt;p&gt;In gEDA there are several places which do exactly this, and they need fixing.&lt;/p&gt;

&lt;h4&gt;Dealing with non-local exits safely&lt;/h4&gt;

&lt;p&gt;Fortunately, Guile provides two mechanisms for dealing with this, called &lt;a href="http://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Continuation-Barriers.html#Continuation-Barriers"&gt;Continuation Barriers&lt;/a&gt; and &lt;a href="http://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Dynamic-Wind.html#Dynamic-Wind"&gt;Dynamic Wind&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Continuation barriers are the less powerful of the two mechanisms, but are simpler to understand.  They simply block both exceptions and continuations from entering or leaving the  context of the barrier call. Here is how to modify the previous example to use a continuation barrier:&lt;/p&gt;

&lt;code&gt;&lt;pre&gt;
void myfunc()
{
  gchar *buf = g_strdup ("const string");
  scm_c_with_continuation_barrier (anotherfunc, buf);
  g_free (buf);
}
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;There's an obvious disadvantage to this approach: you can't catch and handle exceptions which occur, or allow exceptions to propagate upward to the function that called &lt;tt&gt;myfunc()&lt;/tt&gt; in case they can be caught and handled there!&lt;/p&gt;

&lt;p&gt;Dynamic wind provides a more flexible method. The &lt;tt&gt;scm_dynwind_start()&lt;/tt&gt; and &lt;tt&gt;scm_dynwind_end()&lt;/tt&gt; functions delimit a &lt;strong&gt;dynamic extent&lt;/strong&gt;, and it's possible to register actions to be carried out whenever the dynamic extent is entered or left (e.g. due to a continuation or exception).  It's also possible to indicate that non-local exits from the dynamic extent are permitted, but non-local entries aren't (this is the usual thing to do when using dynamic wind from C code).&lt;/p&gt;

&lt;p&gt;Here is &lt;tt&gt;myfunc()&lt;/tt&gt; modified to use dynamic wind:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
void myfunc()
{
  /* Begin a dynamic extent that can't be re-entered */
  scm_dynwind_begin (0);

  gchar *buf = g_strdup ("const string");

  /* Make sure that buf is freed when the dynamic extent is
   * left either locally or non-locally */
  scm_dynwind_unwind_handler (g_free, buf, SCM_F_WIND_EXPLICITLY);

  anotherfunc (buf);

  /* End dynamic extent */
  scm_dynwind_end ();
}
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;This ensures that &lt;tt&gt;buf&lt;/tt&gt; is always freed. If &lt;tt&gt;anotherfunc()&lt;/tt&gt; raises an exception, or it calls a continuation that jumps out of &lt;tt&gt;myfunc()&lt;/tt&gt;, the unwind handler will make sure that the string is freed. Since the &lt;tt&gt;SCM_F_WIND_EXPLICITLY&lt;/tt&gt; flag was passed to &lt;tt&gt;scm_dynwind_unwind_handler()&lt;/tt&gt;, the handler will also be called if the call to &lt;tt&gt;scm_dynwind_end()&lt;/tt&gt; is reached and the function returns normally.&lt;/p&gt;

&lt;h4&gt;Conclusion&lt;/h4&gt;

&lt;p&gt;One task that's well past due is a review of functions in gEDA that call into Scheme to make sure that they safely handle non-local exits, either by using continuation barriers, dynamic wind, or the "protected" functions provided in &lt;tt&gt;libgeda&lt;/tt&gt; (see &lt;tt&gt;libgeda/src/g_basic.c&lt;/tt&gt;).  This would be ideal for someone less familiar with the code base to tackle, since it can be approached on a function-by-function basis.&lt;/p&gt;

&lt;p&gt;In my next post, I will describe how to set up your environment to get notifications about use of deprecated &lt;tt&gt;libguile&lt;/tt&gt; API usage in gEDA, and in particular the problems caused by the continued use of the long-deprecated &lt;tt&gt;SCM_STRING_CHARS&lt;/tt&gt; macro.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-6314681632686863801?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=6314681632686863801' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/6314681632686863801'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/6314681632686863801'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2011/06/geda-and-guile-safe-handling-of-non.html' title='gEDA and Guile — safe handling of non-local exits'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-6384933199595362334</id><published>2011-06-09T10:02:00.011+01:00</published><updated>2011-06-16T14:16:33.900+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gEDA'/><title type='text'>gEDA and Guile — compiling against multiple Guile versions</title><content type='html'>&lt;p&gt;This is the second in a series of blog posts on extensibility in gEDA using &lt;a href="http://www.gnu.org/s/guile/"&gt;Guile Scheme&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-finding-scheme-api-code.html"&gt;Finding Scheme API code in gEDA&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Compiling against multiple Guile versions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-safe-handling-of-non.html"&gt;Safe handling of non-local exits&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-dealing-with-deprecated.html"&gt;Dealing with deprecated &lt;tt&gt;libguile&lt;/tt&gt; functions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-checking-arguments-to.html"&gt;Checking arguments to Scheme functions in C&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-how-and-when-to-use.html"&gt;How and when to use Scheme errors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-reducing-boilerplate.html"&gt;Reducing boilerplate with "snarfing macros"&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-opportunities-to-get.html"&gt;Opportunities to get involved&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this post, I'll explain how to set up your build environment in such a way that you can easily compile gEDA against either Guile 1.8 or Guile 2.0, since we need to support using gEDA with either version of Guile at the moment.&lt;/p&gt;

&lt;p&gt;Firstly, you need to build and install Guile 2.0 and Guile 1.8 to their own prefixes, e.g. &lt;tt&gt;/opt/guile-2.0/&lt;/tt&gt; and &lt;tt&gt;/opt/guile-1.8/&lt;/tt&gt;.&lt;/p&gt;

&lt;code&gt;
$ wget &lt;a href="ftp://ftp.gnu.org/gnu/guile/guile-2.0.1.tar.gz"&gt;ftp://ftp.gnu.org/gnu/guile/guile-2.0.1.tar.gz&lt;/a&gt;&lt;br/&gt;
$ tar -zxf guile-2.0.1.tar.gz&lt;br/&gt;
$ cd guile-2.0.1&lt;br/&gt;
$ ./configure --prefix=/opt/guile-2.0&lt;br/&gt;
$ make&lt;br/&gt;
$ sudo make install&lt;br/&gt;
&lt;br/&gt;
$ wget &lt;a href="ftp://ftp.gnu.org/gnu/guile/guile-1.8.8.tar.gz"&gt;ftp://ftp.gnu.org/gnu/guile/guile-1.8.8.tar.gz&lt;/a&gt;&lt;br/&gt;
$ tar -zxf guile-1.8.8.tar.gz&lt;br/&gt;
$ cd guile-1.8.8&lt;br/&gt;
$ ./configure --prefix=/opt/guile-1.8&lt;br/&gt;
$ make&lt;br/&gt;
$ sudo make install
&lt;/code&gt;

&lt;p&gt;Next, you need to have some way of quickly adding and removing the different versions of Guile to your environment.  Specifically, you need to be able to modify &lt;tt&gt;INFOPATH&lt;/tt&gt;, &lt;tt&gt;PATH&lt;/tt&gt;, &lt;tt&gt;MANPATH&lt;/tt&gt;, &lt;tt&gt;LD_LIBRARY_PATH&lt;/tt&gt; and &lt;tt&gt;PKG_CONFIG_PATH&lt;/tt&gt;.&lt;/p&gt;

&lt;p&gt;The approach I use is to use &lt;a href="http://modules.sourceforge.net/"&gt;Environment Modules&lt;/a&gt; (henceforth referred to as &lt;tt&gt;modules&lt;/tt&gt;).  The idea is to be able to do something like this:&lt;/p&gt;

&lt;code&gt;
$ module load guile/1.8&lt;br/&gt;
$ which guile&lt;br/&gt;
/opt/guile-1.8/bin/guile&lt;br/&gt;
$ module switch guile guile/2.0&lt;br/&gt;
$ which guile&lt;br/&gt;
/opt/guile-2.0/bin/guile
&lt;/code&gt;

&lt;p&gt;One particularly neat thing about &lt;tt&gt;modules&lt;/tt&gt; is that although I give all my examples here for POSIX &lt;tt&gt;sh&lt;/tt&gt; and/or &lt;tt&gt;bash&lt;/tt&gt;, the same module files can be used with other shells such as &lt;tt&gt;tcsh&lt;/tt&gt; with no modification.&lt;/p&gt;

&lt;h4&gt;Installing &amp; setting up Environment Modules&lt;/h4&gt;

&lt;p&gt;Unfortunately, &lt;tt&gt;modules&lt;/tt&gt; can be a bit of a pain to install, and many distributions don't appear to package it. This is a guide to getting it working on Ubuntu 10.04; it's much easier on Fedora, since there you can just install the &lt;tt&gt;environment-modules&lt;/tt&gt; package.&lt;/p&gt;

&lt;p&gt;Due to a really obnoxious default file layout that's not at all trivial to fix, it's easiest to install &lt;tt&gt;modules&lt;/tt&gt; to its own prefix, e.g. &lt;tt&gt;/opt/Modules&lt;/tt&gt;. You'll need to do something like this (after downloading &lt;a href="http://sourceforge.net/projects/modules/files/Modules/modules-3.2.8/modules-3.2.8a.tar.gz/download"&gt;the source code&lt;/a&gt;):&lt;/p&gt;

&lt;code&gt;
$ tar -zxf modules-3.2.8a.tar.gz&lt;br/&gt;
$ ./configure --disable-versioning --prefix=/opt&lt;br/&gt;
$ make&lt;br/&gt;
$ sudo make install
&lt;/code&gt;

&lt;p&gt;It's then necessary to set up your &lt;tt&gt;~/.bash_profile&lt;/tt&gt; and &lt;tt&gt;~/.bashrc&lt;/tt&gt; to enable modules for your sessions. Firstly, you need to add some boilerplate to the top of &lt;tt&gt;~/.bash_profile&lt;/tt&gt;:&lt;/p&gt;

&lt;code&gt;
if [ -f /opt/Modules/init/bash ]&lt;br/&gt;
then&lt;br/&gt;
  # Set the file to store your initial environment in&lt;br/&gt;
  export MODULESBEGINENV=$HOME/.modules/beginenv&lt;br/&gt;
  # Initialise environment for modules&lt;br/&gt;
  . /opt/Modules/init/bash&lt;br/&gt;
  # Set a directory for your personal module files (create this directory)&lt;br/&gt;
  module use $HOME/.modules&lt;br/&gt;
  # Load some default modules&lt;br/&gt;
  module load guile&lt;br/&gt;
fi
&lt;/code&gt;

&lt;p&gt;It's also useful add this to your &lt;tt&gt;~/.bashrc&lt;/tt&gt;, to make sure that when you start a new shell your environment is preserved:&lt;/p&gt;

&lt;code&gt;
if [ ! -z "$MODULESHOME" ]; then&lt;br/&gt;
  module() { eval `$MODULESHOME/bin/modulecmd bash $*`; }&lt;br/&gt;
&lt;br/&gt;
  module update # Need to reload modules because of setuid utmp&lt;br/&gt;
fi
&lt;/code&gt;

&lt;h4&gt;Creating modules for Guile versions&lt;/h4&gt;

&lt;p&gt;The next step is to make the module files for the two versions of Guile.  These will be called &lt;tt&gt;/opt/Modules/modulefiles/guile/1.8&lt;/tt&gt; and &lt;tt&gt;/opt/Modules/modulefiles/guile/2.0&lt;/tt&gt;, and will look like this:&lt;/p&gt;

&lt;code&gt;
#%Module1.0&lt;br/&gt;
prepend-path PATH /scratch/opt/guile-2.0/bin&lt;br/&gt;
prepend-path LD_LIBRARY_PATH /scratch/opt/guile-2.0/lib&lt;br/&gt;
prepend-path PKG_CONFIG_PATH /scratch/opt/guile-2.0/lib/pkgconfig&lt;br/&gt;
prepend-path INFOPATH /scratch/opt/guile-2.0/share/info&lt;br/&gt;
prepend-path MANPATH /scratch/opt/guile-2.0/share/man
&lt;/code&gt;

&lt;p&gt;with 2.0 replaced by 1.8 for &lt;tt&gt;/opt/Modules/modulefiles/guile/1.8&lt;/tt&gt;.&lt;/p&gt;

&lt;p&gt;Finally, it's necessary to tell &lt;tt&gt;modules&lt;/tt&gt; which version of Guile should be the default, for when a user asks for &lt;tt&gt;module load guile&lt;/tt&gt;. We can do this by adding a &lt;tt&gt;/opt/Modules/modulefiles/guile/.modulerc&lt;/tt&gt; file.&lt;/p&gt;

&lt;code&gt;
#%Module1.0&lt;br/&gt;
set ModulesVersion 2.0
&lt;/code&gt;

&lt;h4&gt;Putting it all together&lt;/h4&gt;

&lt;p&gt;After re-initialising your session (probably easiest to log out and back in again), you should be able to swap between versions of Guile using &lt;tt&gt;module load&lt;/tt&gt; and &lt;tt&gt;module switch&lt;/tt&gt; as described above.&lt;/p&gt;

&lt;p&gt;You should now be easily able to compile gEDA against either version of Guile without too much difficulty — simply load the appropriate environment module, and then run:&lt;/p&gt;

&lt;code&gt;
$ ./config.status --recheck &amp;&amp; ./config.status &amp;&amp; make
&lt;/code&gt;

&lt;p&gt;In my next post I will discuss one of the problems that's quite common in gEDA's use of Guile: unsafe behaviour on non-local exits such as Scheme exceptions.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-6384933199595362334?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=6384933199595362334' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/6384933199595362334'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/6384933199595362334'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2011/06/geda-and-guile-compiling-against.html' title='gEDA and Guile — compiling against multiple Guile versions'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-296833712078233869</id><published>2011-06-08T15:11:00.006+01:00</published><updated>2011-06-16T14:15:47.288+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gEDA'/><title type='text'>gEDA and Guile — finding Scheme API code in gEDA</title><content type='html'>&lt;p&gt;The response to &lt;a href="http://blog.peter-b.co.uk/2011/06/porting-geda-to-guile-20-and-future.html"&gt;my previous post&lt;/a&gt; was overwhelmingly in favour of continuing and merging my work on gEDA extensibility using &lt;a href="https://www.gnu.org/s/guile/"&gt;Guile Scheme&lt;/a&gt;, both here and on the gEDA mailing lists. Some people asked how they could help out, and so I'm going to write a series of blog posts with some information on how gEDA uses Scheme and some easy introductory tasks that would be useful.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Finding Scheme API code in gEDA&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-compiling-against.html"&gt;Compiling against multiple Guile versions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-safe-handling-of-non.html"&gt;Safe handling of non-local exits&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-dealing-with-deprecated.html"&gt;Dealing with deprecated &lt;tt&gt;libguile&lt;/tt&gt; functions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-checking-arguments-to.html"&gt;Checking arguments to Scheme functions in C&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-how-and-when-to-use.html"&gt;How and when to use Scheme errors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-reducing-boilerplate.html"&gt;Reducing boilerplate with "snarfing macros"&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-opportunities-to-get.html"&gt;Opportunities to get involved&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this blog post, I'll explain where Guile is used in gEDA at the moment, both C code using &lt;tt&gt;libguile&lt;/tt&gt; and Scheme code itself.&lt;/p&gt;

&lt;h4&gt;What is Scheme used for?&lt;/h4&gt;
&lt;p&gt;Currently, Guile is used for:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Executing "configuration" files (actually initialisation files) written in Scheme, in all &lt;tt&gt;libgeda&lt;/tt&gt; applications.
&lt;/li&gt;&lt;li&gt;Setting up the menus and keybindings in &lt;tt&gt;gschem&lt;/tt&gt;. Key sequences and menu items call Scheme "thunks" (functions of no arguments), which are mostly implemented in C. It's not currently feasible to create a meaningful new action in  &lt;tt&gt;gschem&lt;/tt&gt; without writing it mostly in C.
&lt;/li&gt;&lt;li&gt;Exporting netlists in &lt;tt&gt;gnetlist&lt;/tt&gt;. A &lt;tt&gt;gnetlist&lt;/tt&gt; backend generates particular on-disk netlist file format using a limited API that provides access to the compiled netlist.&lt;/li&gt;&lt;li&gt;A few other things (mostly incomplete). For example, there is a very limited existing Scheme API spread between &lt;tt&gt;gschem&lt;/tt&gt; and &lt;tt&gt;libgeda&lt;/tt&gt; for taking actions on changes to pages and/or attributes.&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;It would be nice to do more things (like extending  &lt;tt&gt;gschem&lt;/tt&gt; with additional actions written in pure Scheme, or being able to modify the way that  &lt;tt&gt;gnetlist&lt;/tt&gt; compiles a netlist from input schematics).&lt;/p&gt;

&lt;h4&gt;Where is the Guile code in gEDA?&lt;/h4&gt;

&lt;p&gt;In the C sources, files which contain code using &lt;tt&gt;libguile&lt;/tt&gt; usually begin with the prefix "&lt;tt&gt;g_&lt;/tt&gt;". For example, "&lt;tt&gt;g_rc.c&lt;/tt&gt;" contains definitions of functions used for configuration parameters, and "&lt;tt&gt;g_register.c&lt;/tt&gt;" contains code for registering C functions and variables to be visible from Scheme. There are a bunch of exceptions to be aware of, which include:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;tt&gt;libgeda/src/s_clib.c&lt;/tt&gt; contains some &lt;tt&gt;libguile&lt;/tt&gt; code that permits component libraries to be defined as a set of Scheme functions.
&lt;/li&gt;&lt;li&gt;&lt;tt&gt;libgeda/src/s_menu.c&lt;/tt&gt; contains some basic infrastructure for menu definitions in Scheme rc files that's past due to move into &lt;tt&gt;gschem&lt;/tt&gt;.&lt;/li&gt;&lt;li&gt;&lt;tt&gt;libgeda/src/s_menu.c&lt;/tt&gt; has functions for converting gEDA colour map data to and from Scheme representations.&lt;/li&gt;&lt;li&gt;Several &lt;tt&gt;gschem&lt;/tt&gt; source files contain snippets of  &lt;tt&gt;libguile&lt;/tt&gt; code for firing hooks when the user carries out certain actions.&lt;/li&gt;&lt;li&gt;&lt;tt&gt;gschem/src/x_menus.c&lt;/tt&gt; implements menus defined in Scheme, and &lt;tt&gt;gschem/src/x_stroke.c&lt;/tt&gt; provides support for assigning gestures to actions in Scheme (which capability I'm not sure I've ever used).&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;More generally, you can usually find code that uses &lt;tt&gt;libguile&lt;/tt&gt; by searching for the "&lt;tt&gt;scm_&lt;/tt&gt;" or "&lt;tt&gt;SCM_&lt;/tt&gt;" prefix used by &lt;tt&gt;libguile&lt;/tt&gt; functions, macros and variables.&lt;/p&gt;

&lt;p&gt;Most of the application directories in the gEDA source tree have a "&lt;tt&gt;scheme&lt;/tt&gt;" subdirectory where most of the "&lt;tt&gt;.scm&lt;/tt&gt;" files with Scheme code live.  There are also the system rc files for each application, which are also written in Scheme but for some reason live in "&lt;tt&gt;lib&lt;/tt&gt;" subdirectories.&lt;/p&gt;

&lt;p&gt;So that's a brief overview of where the Scheme-related code lives in gEDA.  In my next post, I will talk about &lt;a href="http://blog.peter-b.co.uk/2011/06/geda-and-guile-compiling-against.html"&gt;how to set up your build environment&lt;/a&gt; to be able to easily build against either Guile 1.8 or Guile 2.0.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-296833712078233869?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=296833712078233869' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/296833712078233869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/296833712078233869'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2011/06/geda-and-guile-finding-scheme-api-code.html' title='gEDA and Guile — finding Scheme API code in gEDA'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-2519849430000894403</id><published>2011-06-05T11:41:00.004+01:00</published><updated>2011-06-08T16:41:29.674+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gEDA'/><title type='text'>Porting gEDA to Guile 2.0, and future plans</title><content type='html'>&lt;p&gt;Guile, a Scheme implementation that's part of the GNU project, recently put out a new 2.0 release with many exciting new features and improvements.&lt;/p&gt;
&lt;p&gt;gEDA relies on Guile for extensibility. In the past we have had a few problems moving to new versions of Guile, often due to differences between memory management APIs or library functions.&lt;/p&gt;
&lt;p&gt;I first started looking at Guile 2.0 support in gEDA in December 2010. At the time, I had great difficulty getting libgeda to work due to differences in the debugging APIs between Guile 1.8 and 2.0. However, during January I did a considerable amount of work on how Scheme errors are reported in libgeda, and as part of that I managed to do things in a way compatible with both versions of Guile.&lt;/p&gt;
&lt;p&gt;Last Friday I was therefore able to get gEDA fully working with Guile 2.0. Actually, the main remaining obstacle was that the new version of Guile is much stricter about correct Scheme syntax, and some of the gnetlist backends needed fixing up.&lt;/p&gt;
&lt;p&gt;But that's done, and gEDA is now fully compatible with Guile 2.0 and can take advantage of the performance improvements it brings!&lt;/p&gt;
&lt;p&gt;What's next for me in terms of gEDA development? Well, I still have several different development branches on the go, and I'm not sure which of them (if any) to focus on.&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;I have a branch which extensively refactors, extends and improves the libgeda scheme API, with the intention of making it possible to write much more fully-featured plugins &amp;amp; extensions for gschem and gnetlist.&lt;/li&gt;&lt;li&gt;I have done a lot of work on splitting the cairo rendering code out of gschem into a separate library called libgedacairo, in order to make it easier to write applications that display gEDA schematics or convert them to other graphics formats. (As part of of this work, I'm also modifying gschem to take advantage of the GTK+ printing APIs).&lt;/li&gt;&lt;li&gt;I have a design for a new configuration system for gEDA, which is non-executable and can provide per-schematic-page configuration. This is intended to remove a security flaw in gEDA at the moment when opening designs received from others.&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Or are there other, more urgent things that need work? let me know what you think.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-2519849430000894403?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=2519849430000894403' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/2519849430000894403'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/2519849430000894403'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2011/06/porting-geda-to-guile-20-and-future.html' title='Porting gEDA to Guile 2.0, and future plans'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-6556156165305806702</id><published>2011-04-12T08:26:00.005+01:00</published><updated>2011-04-15T09:57:40.347+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='research'/><title type='text'>Papers presented at JURSE 2011</title><content type='html'>&lt;p&gt;I'm presenting two papers at this year's Joint Urban Remote Sensing Event being held in Munich this week. The proceedings are not yet available on IEEE Xplore, but I have made preprints available on my website.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;P.T.B. Brett and R. Guida. Bright line detection in COSMO-SkyMed SAR images of urban areas. In &lt;i&gt;Joint Urban Remote Sensing Event 2011 (JURSE 2011)&lt;/i&gt;, pages 253-256, 11-13 April 2011. &lt;a href="http://peter-b.co.uk/downloads/brett_guida_2011.preprint.pdf"&gt;[Preprint]&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;R. Guida and P.T.B. Brett. A SAR image-based tool for prompt and effective earthquake response. In &lt;i&gt;Joint Urban Remote Sensing Event 2011 (JURSE 2011)&lt;/i&gt;, pages 213-216, 11-13 April 2011. &lt;a href="http://peter-b.co.uk/downloads/guida_brett_2011.preprint.pdf"&gt;[Preprint]&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-6556156165305806702?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=6556156165305806702' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/6556156165305806702'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/6556156165305806702'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2011/04/papers-presented-at-jurse-2011.html' title='Papers presented at JURSE 2011'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-6424047213582794511</id><published>2011-03-26T11:22:00.001Z</published><updated>2011-03-26T11:23:55.159Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='ppuk'/><title type='text'>Weekly News Stash</title><content type='html'>&lt;p&gt;There have been a large number of blog posts and news stories over
the last week that I found interesting, but I didn't have time to blog
on each of them individually. Instead, here are the highlights. I've
probably missed a bunch of relevant stuff, so please feel free to
point them out in the comments.&lt;/p&gt;
&lt;h4&gt;Libya and Wikileaks&lt;/h4&gt;
&lt;p&gt;Tom Watson (MP for Bromwich West) posted on his blog to assert that
the UN and allied intervention in the Libyan insurgency (or uprising
or civil war, depending on your perspective) constitutes "the first &lt;a
href="http://tomwatson.typepad.com/tom_watson/2011/03/the-wikileaks-war.html"&gt;Wikileaks
war&lt;/a&gt;".&lt;/p&gt;
&lt;blockquote&gt;
Understandably, this development blows the minds of liberals who have
stoically supported WikiLeaks as an innovative new international
information movement that would almost certainly deflate the
interventionist and imperialist tendencies of the big western powers…
the smartest pro-transparency analysts have always realized that the
revelations the U.S. cables represented would almost certainly lead to
unforeseen consequences, if not armed conflict.
&lt;/blockquote&gt;
&lt;p&gt;I'm not sure I entirely agree that one can entirely lay the blame
for the situation at the door of Wikileaks.  I believe that the rise
of social networking (especially Twitter and Facebook) as well as
citizen journalism via blogging and video sharing sites such as
YouTube have played as much as an enabling role — or perhaps even more
so.&lt;/p&gt;
&lt;p&gt;In related news, Bradley Manning, the US serviceman accused of
being responsible for the leaking of large amouts of classified US
embassy cables (among other materials) has now been incarcerated in
solitary confinement and and subjected to routine psychological
torture for over 300 days. Whether or not you consider him a criminal
and deserving of punishment, I believe that "no-touch torture" is
still torture, torture is barbaric and should never occur in a country
that considers itself civilised, and that Bradley's rights both to a
speedy trial and to be considered innocent until proven guilty have
both been brutally violated. Loz Kaye, leader of the Pirate Party UK,
gave a very well received speech on the subject at last Sunday's
protest outside the US Embassy in Grosvenor Square.&lt;/p&gt;

&lt;h4&gt;Engagement with the Liberal Democrats&lt;/h4&gt;

&lt;p&gt;Loz also was recently invited to take part in a panel session on
"&lt;a
href="http://www.libdemvoice.org/podcast-who-controls-the-internet-23421.html"&gt;Who
controls the Internet?&lt;/a&gt;" at the Liberal Democrat party conference,
and subsequently contributed a blog post on &lt;a
href="http://www.libdemvoice.org/?p=23478"&gt;the Pirate Party
perspective&lt;/a&gt; to the Lib Dem Voice blog.&lt;/p&gt;
&lt;p&gt;Both his article and the comments are worth a read. In particular,
they demonstrate that even within the Lib Dems, opinion is heavily
divided on the issues of Internet governance and intellectual property
policy and enforcementt. A microcosm of this, of course, can be seen
in Parliament; contrast the behaviour Lord Clement-Jones in the Lords
and Julian Huppert, MP for Cambridge, in the Commons.&lt;/p&gt;

&lt;h4&gt;In academia&lt;/h4&gt;

&lt;p&gt;There have been several interesting news stories from academic
research in the last week.&lt;/p&gt;
&lt;p&gt;Firstly, a paper from Joel Waldfogel, an economist at the
University of Minnesota. He carried out some research into claims by
the recording industry that copyright infringement was stopping new
music or new artists coming to market, and published a paper on his
results, whimsically entitled "Bye, Bye, Miss American Pie?"  Not only
was he unable to find any evidence that the rise of Napster and
peer-to-peer filesharing have resulted in an impact on either, but he
also found that there has been a significant shift from the major
labels to independent labels in the releasing of new music. (More
coverage from &lt;a
href="http://www.michaelgeist.ca/content/view/5700/196/"&gt;Michael
Geist&lt;/a&gt;, &lt;a
href="http://torrentfreak.com/report-despite-piracy-music-is-more-alive-than-ever-before-110325/"&gt;TorrentFreak&lt;/a&gt;
and &lt;a href=""&gt;Techdirt&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;The 1709 blog reported on a talk given by Professor Paul Heald
entitled "&lt;a
href="http://the1709blog.blogspot.com/2011/03/do-bad-things-happen-when-works-fall.html"&gt;Do
bad things happen when works fall into the public domain?&lt;/a&gt;".  In
particular he debunked both the assertion that falling into the public
domain will lead to underusage of works, and that it will result in
the devaluation of works. I note that he's published on the subject,
and I'm going to try to get hold of his papers, as they sound like
they will be interesting reading.&lt;/p&gt;

&lt;p&gt;From the London School of Economics there came &lt;a
href="http://blogs.lse.ac.uk/mediapolicyproject/2011/03/21/media-policy-project-policy-brief-1-creative-destruction-and-copyright-protection/"&gt;a
highly critical report&lt;/a&gt; on the deservedly-maligned Digital Economy
Act 2010, called "Creative Destruction and Copyright Protection." In
particular, it has this to say:&lt;/p&gt;
&lt;blockquote&gt;
The DEA gets the balance between copyright enforcement and innovation
wrong. The use of peer-to-peer technology should be encouraged to
promote innovative applications. Focusing on efforts to suppress the
use of technological advances and to protect out-of-date business
models will stifle innovation in this industry.
&lt;/blockquote&gt;

&lt;p&gt;Another article critical of the DEA has been published by William
Dutton at the University of Oxford. Called "&lt;a
href="http://papers.ssrn.com/sol3/papers.cfm?abstract_id=1778422"&gt;Aiming
at Copyright Infringers and Hitting the Digital Economy&lt;/a&gt;", it
argues strongly that the Act will not only not achieve its stated
objectives, but will in fact have several negative effects. The
article actually mentions the Pirate movement, and quotes from the
PPUK manifesto!&lt;/p&gt;

&lt;p&gt;It's nice to see academia providing some objective criticism of the
oft-repeated claims of the copyright industries — claims which so far
no independent research has been able to substantiate or reproduce,
despite how often they crop up.&lt;/p&gt;

&lt;h4&gt;In the courts&lt;/h4&gt;

&lt;p&gt;The High Court hearings for the judicial review of the
aforementioned Digital Economy Act are currently taking place. They
started last Wednesday, and are expected to conclude sometime next
week. Will Tovey has &lt;a
href="http://www.pirateparty.org.uk/blog/2011/mar/23/digital-economy-act-trial/"&gt;posted&lt;/a&gt;
some &lt;a
href="http://www.pirateparty.org.uk/blog/2011/mar/25/defending-digital-economy-act/"&gt;commentary&lt;/a&gt;
on the Pirate Party UK blog. Summary: no matter what the outcome, the
result is almost certain to be appealed, and it's quite likely to go
all the way to the European Court of Justice, meaning that we could be
looking at a couple of years before the final outcome is decided.&lt;/p&gt;

&lt;p&gt;The big headline his week is that a selection of record labels are
suing the company behind the Limewire filesharing software for a total
of 75 &lt;em&gt;trillion&lt;/em&gt; US dollars (to be precise,
$&amp;nbsp;7.5x10&lt;sup&gt;13&lt;/sup&gt;) in statutory damages. To put that into
perspective, the GDP of the entire world is only $75.5 trillion, and
the global money supply is only approx. $50 trillion. It would
therefore be accurate to say that Limewire is being sued for &lt;em&gt;all
the money in the world&lt;/em&gt;. I consider this excellent evidence for
the fact that &lt;em&gt;the statutes are wrong&lt;/em&gt;. This &lt;a
href="http://yro.slashdot.org/comments.pl?sid=2051190&amp;amp;cid=35591762"&gt;Slashdot
comment&lt;/a&gt; was the best take on the ridiculous situation that I've
read so far.&lt;/p&gt;

&lt;blockquote&gt;
Now how in the hell does that promote "progress of the arts and
sciences"? Answer: it doesn't, it is simply a way for a "leecher
class" to make eternal checks off locking up the entire culture of a
race. How many works have already been lost simply because nobody
could legally make a copy and the copyright holders couldn't figure
out a way to "monetize the IP" and just let it rot?
&lt;/blockquote&gt;

&lt;p&gt;That's it for this week. Hopefully next week there won't be quite so many items that I'm desperate to share with the world!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-6424047213582794511?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=6424047213582794511' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/6424047213582794511'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/6424047213582794511'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2011/03/weekly-news-stash.html' title='Weekly News Stash'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-3654578750147863208</id><published>2011-03-23T14:15:00.003Z</published><updated>2011-03-26T11:44:11.690Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='ppuk'/><title type='text'>Survey on "Open Standards in the Public Sector"</title><content type='html'>&lt;div xmlns='http://www.w3.org/1999/xhtml'&gt;

&lt;p&gt;The Cabinet Office is currently carrying out &lt;a href='http://www.cabinetoffice.gov.uk/content/uk-government-open-standards-survey'&gt;a
survey on "Open Standards in the Public Sector"&lt;/a&gt;. The widespread
use of open standards in government would be a major step forward for
the UK, both in terms of stimulating innovation in the IT sector by
lowering barriers for entry in the public sector, and in terms of
ensuring that everybody is able to use and interact with UK government
online services without being required to use a particular software
platform or limited set of platforms.&lt;/p&gt;

&lt;p&gt;Two areas of the survey were of particular interest to me: the
opening section on defining what exactly an "open standard" is, and
the section on standards that are being evaluated for computer
workstations. The survey, however, covers a huge array of areas for
possible standardisation in IT (for example, content syndication,
e-voting, web services and VoIP), and there's lots of scope for people
with domain-specific knowledge to contribute on the areas that they're
most familiar with.&lt;/p&gt;

&lt;p&gt;I encourage everyone who is interested in seeing increased adoption
of open standards in governmental IT procurement to take part in this
survey — and in particular, to encourage the UK to standardise
on PDF and OpenDocument rather than Microsoft's bought-and-paid-for
non-standard, Office "Open" XML.&lt;/p&gt;

&lt;h4&gt;What is an open standard?&lt;/h4&gt;

&lt;p&gt;The survey outlines five conditions for an open standard that the
government proposes:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;1. Open standards are standards which result from and are maintained
through an open, independent process.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Open standards need not necessarily result from an open and
independent process -- as a classic example, the Internet Protocol and
Transmission Control Protocol (TCP/IP) on which the Internet is based
were developed behind closed doors by a small working group at
Stanford in the early 1970s. However, I would agree that the success
of TCP/IP as an open standard has very much depended on the fact that
it has been maintained by an open and independent organisation (the
IETF).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;2. Open standards are standards which are approved by a recognised
specification or standardisation organisation, for example W3C or ISO
or equivalent.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There are two sources of concern with this condition. Firstly, it is
unclear who maintains the list of "recognised" specification or
standardisation organisations, nor how such an organisation can become
"standardised", and greater clarity would be appreciated. Secondly,
the ISO in particular operates extremely slowly, and waiting for ISO
standardisation of an already-widely-used open standard may well
hamper flexibility and responsiveness in government
procurement. However, in principle this condition seems a sensible
one.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;3. Open standards are standards which are thoroughly documented and
publicly available at zero or low cost.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is an essential condition. If a standard's documentation cannot
be be easily and inexpensively obtained, it provides a serious barrier
to individuals, small companies and community organisations that wish
to implement and use that standard.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;4. Open standards are standards which have intellectual property made
irrevocably available on a royalty free basis.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This condition is important in order to avoid the risk that
corporations with intellectual property interests in a standard wait
until the standard has widespread adoption before introducing or
substantially increasing royalties.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;5. Open standards are standards which as a whole can be implemented
and shared under different development approaches and on a number of
platforms.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is the key condition, and cuts to the heart of the reason open
standards are needed. Some standards organisations require at least
two independent, full implementations of a standard to exist before
adopting the standard, and I would commend this approach to the
Government.&lt;/p&gt;

&lt;h4&gt;Standards for computer workstations&lt;/h4&gt;

&lt;p&gt;Many of the standards listed in this section of the survey are
sadly nothing of sort were not open, and many of them weren't
standards either. Highlights that I particularly enjoyed included:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The presence of .doc, .xls and .ppt files as a "standard", and
  inclusion of Microsoft's Office Open XML, which is hardly
  "open".&lt;/li&gt;
  &lt;li&gt;HTML as an document format for presentations and spreadsheet
  data.&lt;/li&gt;
  &lt;li&gt;A section on video/animation formats that included &lt;em&gt;no open
  standards whatsoever&lt;/em&gt;, and included .swf files (neither open nor
  standardised) twice.&lt;/li&gt;
  &lt;li&gt;It was heartening, however, to see Open Document Format listed,
  along with Unicode and UCS (although why Unicode isn't already
  mandatory is beyond me).&lt;/li&gt;
&lt;/ul&gt;

    &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-3654578750147863208?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=3654578750147863208' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/3654578750147863208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/3654578750147863208'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2011/03/survey-on-standards-in-public-sector.html' title='Survey on &amp;quot;Open Standards in the Public Sector&amp;quot;'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-8872562382534548731</id><published>2011-03-17T10:25:00.002Z</published><updated>2011-03-17T10:25:55.571Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='cooking'/><title type='text'>Beef shin hotpot</title><content type='html'>&lt;div xmlns='http://www.w3.org/1999/xhtml'&gt;


&lt;p&gt;The cheesecake I described in &lt;a href='http://blog.peter-b.co.uk/2011/02/seattle-cheesecake-recipe.html'&gt;my
last blog post&lt;/a&gt; was absolutely delicious!&lt;/p&gt;

&lt;p&gt;I enjoy eating beef, but the most well-known cuts are quite
expensive. &lt;a href='https://secure.wikimedia.org/wikipedia/en/wiki/Beef#UK_primal_cuts'&gt;Shin&lt;/a&gt;
is a less-commonly used cut (you probably won't find it in
Sainsbury's), but is still delicious in stews and hotpots as long as
you cook it correctly!  Ask for it at the butcher or at a farmers'
market.  Here's a shin hotpot I enjoy making — this recipe
serves 4-6.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;450 g shin of beef, boned and diced&lt;/li&gt;
  &lt;li&gt;2 tbsp sherry vinegar&lt;/li&gt;
  &lt;li&gt;1 tbsp plain flour&lt;/li&gt;
  &lt;li&gt;6 pork sausages&lt;/li&gt;
  &lt;li&gt;450 g potatoes&lt;/li&gt;
  &lt;li&gt;1 dessert (eating) apple&lt;/li&gt;
  &lt;li&gt;2 tomatoes&lt;/li&gt;
  &lt;li&gt;1 onion&lt;/li&gt;
  &lt;li&gt;450 ml beef stock&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Put the beef and vinegar in a bowl, and cover with clingfilm.
Marinate for an hour, stirring occasionally.  This softens and
tenderises the meat.&lt;/p&gt;

&lt;p&gt;Pre-heat the oven to 160 °C. &lt;em&gt;Thinly&lt;/em&gt; slice the
potatoes, apple, tomatoes and onion, and cut the sausages into
chunks.&lt;/p&gt;

&lt;p&gt;Drain the beef, and (optionally) pat it dry with paper towels. Toss
the sausage and beef pieces in the flour.&lt;/p&gt;

&lt;p&gt;In a large casserole dish, start building the hotpot with layers of
sliced vegetables and meat:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;1/3 of the potatoes&lt;/li&gt;
  &lt;li&gt;1/2 of the apple, tomato, and onion&lt;/li&gt;
  &lt;li&gt;1/2 of the sausages and beef&lt;/li&gt;
  &lt;li&gt;1/3 of the potatoes&lt;/li&gt;
  &lt;li&gt;The rest of the apple, tomato and onion&lt;/li&gt;
  &lt;li&gt;The rest of the meat&lt;/li&gt;
  &lt;li&gt;A top layer of potatoes (make sure you keep enough back from the
  previous layers to cover the casserole fully!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Give the dish a little shake to help the casserole settle, and add
the stock (it should come about halfway up the casserole).&lt;/p&gt;

&lt;p&gt;Cover and cook in the oven for 2 1/2 hours. For the last 10-15
minutes, take the lid off and turn the oven up to 200 °C to allow
the top layer of potatoes to crisp up.&lt;/p&gt;

&lt;p&gt;Serve in bowls, with plenty of the stock.  Leftovers keep really
well in the fridge!&lt;/p&gt;

    &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-8872562382534548731?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=8872562382534548731' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/8872562382534548731'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/8872562382534548731'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2011/03/beef-shin-hotpot.html' title='Beef shin hotpot'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-216711508973090281</id><published>2011-02-23T16:51:00.004Z</published><updated>2011-03-17T10:27:14.109Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='cooking'/><title type='text'>Seattle Cheesecake recipe</title><content type='html'>&lt;p&gt;Thanks to one of my colleagues, here's the cheesecake recipe I'm going to try to bake this evening.  I've converted the units to metric, scaled the quantities, and added ingredients for a British-style base and an apricot topping.&lt;/p&gt;
&lt;p&gt;Start by greasing a 20&amp;nbsp;cm spring-form tin and lining the base with a round of greaseproof paper. Pre-heat the oven to 160&amp;nbsp;&amp;deg;C.&lt;/p&gt;
&lt;h4&gt;Biscuit base&lt;/h4&gt;
&lt;ul&gt;&lt;li&gt;12 digestive biscuits&lt;/li&gt;
&lt;li&gt;60&amp;nbsp;g unsalted butter&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Crush the biscuits to the consistency of fine breadcrumbs.  Melt butter and mix into crushed biscuits.  Gently press mixture into bottom of tin using the back of a spoon to form a level base. Bake for 10-15 minutes until lightly browned and just set.  Set aside for at least 5 minutes.&lt;/p&gt;
&lt;h4&gt;Bottom layer&lt;/h4&gt;
&lt;ul&gt;&lt;li&gt;625&amp;nbsp;g cream cheese (not reduced fat, premium brand strongly recommended)&lt;/li&gt;
&lt;li&gt;140&amp;nbsp;g caster sugar&lt;/li&gt;
&lt;li&gt;3 large eggs&lt;/li&gt;
&lt;li&gt;15&amp;nbsp;ml/1&amp;nbsp;tbsp vanilla essence&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Mix all the ingredients together thoroughly, and pour onto the base. Bake in the oven for about an hour.  Time needed depends on atmospheric conditions, but when done the top will start to crack.  When done, remove from oven and cool &lt;em&gt;on a cooling rack&lt;/em&gt; for 30 minutes. (The cooling rack is important, as you need to get airflow underneath the cake).&lt;/p&gt;
&lt;h4&gt;Top layer&lt;/h4&gt;
&lt;ul&gt;&lt;li&gt;330&amp;nbsp;ml sour cream&lt;/li&gt;
&lt;li&gt;30&amp;nbsp;g caster sugar&lt;/li&gt;
&lt;li&gt;15&amp;nbsp;ml/1&amp;nbsp;tbsp vanilla essence&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Turn up the oven to 220&amp;nbsp;&amp;deg;C. Once the bottom layer is cool, mix the top layer ingredients together, and pour on top.  Then return to the oven for a further 10 minutes.&lt;/p&gt;
&lt;h4&gt;Topping&lt;/h4&gt;
&lt;ul&gt;&lt;li&gt;1/2 jar apricot preserve&lt;/li&gt;
&lt;li&gt;3-4 fresh apricots&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Slice apricots.  Heat jam in microwave for about 45 seconds, until runny, and spread over top of cheesecake.  Arrange apricots on top.&lt;/p&gt;

&lt;p&gt;I'll update this post later with the results!&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Update:&lt;/b&gt; This worked out really well! The only slight problem was that the tin didn't come away from the sides totally cleanly, but the cake still looked excellent and tasted delicious!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-216711508973090281?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=216711508973090281' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/216711508973090281'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/216711508973090281'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2011/02/seattle-cheesecake-recipe.html' title='Seattle Cheesecake recipe'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-6714779177191373990</id><published>2010-07-06T21:48:00.004+01:00</published><updated>2010-07-06T21:52:48.373+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ppuk'/><title type='text'>Open Source in schools — not an idle fantasy</title><content type='html'>&lt;div xmlns='http://www.w3.org/1999/xhtml'&gt;

&lt;p&gt;One of the policies in
  the &lt;a href='http://www.pirateparty.org.uk/'&gt;Pirate Party UK&lt;/a&gt;'s
  general election manifesto this year was:&lt;/p&gt;
&lt;blockquote&gt;We will encourage the adoption of open source software in
  schools, so that children won't be reliant in the future on buying a
  particular software package from a particular company.&lt;/blockquote&gt;
&lt;p&gt;Here in the UK, I still get odd looks when I say I use Linux almost
  exclusively on my computers.  A widely-held perception seems to be
  that Linux is an esoteric operating system that isn't capable of
  doing a lot of widely-needed tasks.  &lt;em&gt;Certainly&lt;/em&gt; many of my
  friends would never &lt;em&gt;consider&lt;/em&gt; running it on their own
  computers (despite the fact they're almost certain to have at least
  box running Linux in their house — but I digress).&lt;/p&gt;
&lt;p&gt;Open Source in schools is a particularly controversial
  concept. 'But how will school leavers be able to function in the
  Real World if they haven't been taught to use the "industry
  standard" software?' the detractors cry, referring of course to
  Microsoft Office.&lt;/p&gt;
&lt;p&gt;The fact is, though, that Linux has been widely deployed in schools
  all around the world.  The biggest deployment is in Brazil,
  where the Ministry of Education has installed Linux in labs used by
  &lt;a href='http://desktoplinux.com/news/NS9272932512.html'&gt;52 million
  schoolchildren nationwide&lt;/a&gt; — yes, that's &lt;em&gt;fifty-two
  million&lt;/em&gt; — and it's been a great success.  Not only does
  the 'Linux Educacional' distribution, installed in tens of thousands
  of school computer labs, fulfil the day-to-day needs of school ICT
  and computer science teaching, but has lead to a growing market for
  OEM Linux computers in Brazil.  And no, their school leavers seem to
  have no difficulty whatsoever in adapting their IT skills for use in
  the 'real world' (whatever that is), as Brazil continues to have the
  &lt;a href='http://www.computerweekly.com/Articles/2010/06/17/241637/Brazil-IT-struts-the-world-stage.htm'&gt;strongest IT industry in South America&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Aaron Seigo mentioned this and other (huge!) educational Linux
  deployments
  in &lt;a href='http://home.kde.org/~akademy10/videos/Reaching_For_Greatness-Aaron_Seigo.ogv'&gt;his
  keynote speech&lt;/a&gt; at this year's Akademy, the KDE developer
  conference.  It seems to me that Linux — not to mention other
  great Open Source software such as
  &lt;a href='http://www.openoffice.org/'&gt;OpenOffice.org&lt;/a&gt;, &lt;a href='http://www.mozilla-europe.org/en/firefox/'&gt;Firefox&lt;/a&gt;,
  &lt;a href='http://www.blender.org/'&gt;Blender&lt;/a&gt;, &lt;a href='http://audacity.sourceforge.net/'&gt;Audacity&lt;/a&gt;
  and &lt;a href='http://www.inkscape.org/'&gt;Inkscape&lt;/a&gt; — have
  already proven their suitability for use in schools.&lt;/p&gt;
&lt;p&gt;Maybe it's time for British schools to step out of the muddy rut of
  using Microsoft everywhere 'because everybody uses Microsoft', and
  follow the lead of so many other countries in trying something new,
  exciting, and in the long run quite possibly both
  better &lt;em&gt;and&lt;/em&gt; cheaper.&lt;/p&gt;
    &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-6714779177191373990?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=6714779177191373990' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/6714779177191373990'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/6714779177191373990'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2010/07/open-source-in-schools-not-idle-fantasy.html' title='Open Source in schools — not an idle fantasy'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-8884405233719992429</id><published>2010-03-12T22:13:00.001Z</published><updated>2010-03-12T22:13:40.449Z</updated><title type='text'>Blog migration</title><content type='html'>
    &lt;div xmlns='http://www.w3.org/1999/xhtml'&gt;

&lt;p&gt;Since &lt;a href='http://www.blogger.com/'&gt;Blogger&lt;/a&gt;
  are &lt;a href='http://blogger-ftp.blogspot.com/2010/01/deprecating-ftp.html'&gt;discontinuing
  FTP and SFTP publishing&lt;/a&gt; at the beginning of May, I've now
  migrated my blog to being hosted by a Blogger "custom
  domain", &lt;tt&gt;&lt;a href='http://blog.peter-b.co.uk/'&gt;http://blog.peter-b.co.uk&lt;/a&gt;&lt;/tt&gt;.&lt;/p&gt;
&lt;p&gt;Fortunately, I've been able to use a &lt;tt&gt;.htaccess&lt;/tt&gt; file to add
  a &lt;a href='http://httpd.apache.org/docs/1.3/mod/mod_alias.html#redirect'&gt;mod_alias
  Redirect directive&lt;/a&gt; that ensures that old links to
  &lt;tt&gt;http://peter-b.co.uk/blog/&lt;/tt&gt; will continue to work.  So that
  makes it a lot less of a hassle!&lt;/p&gt;
&lt;p&gt;What was a hassle was figuring out the CSS to disable the Blogger
  navbar, since it completely destroyed the harmony of my site design.
  It's hard to believe that it's almost seven years old! I should
  probably break out the text editor and update it at some point, but
  after this long I can hardly remember how to use CSS and HTML; I've
  got a lot of catching up to do.&lt;/p&gt;
    &lt;/div&gt;
  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-8884405233719992429?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=8884405233719992429' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/8884405233719992429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/8884405233719992429'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2010/03/blog-migration.html' title='Blog migration'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-4257058739345403506</id><published>2010-03-12T20:33:00.004Z</published><updated>2011-02-23T17:31:30.663Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='cooking'/><title type='text'>Banana and walnut cake</title><content type='html'>&lt;div xmlns='http://www.w3.org/1999/xhtml'&gt;

&lt;p&gt;A cake recipe that I've had some success with recently is this
  rather delicious banana and walnut cake. It's dead simple, and takes
  very little time to make. There's one in the oven right now!&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;450&amp;nbsp;g ripe bananas (weighed before peeling), mashed&lt;/li&gt;
  &lt;li&gt;125&amp;nbsp;g unsalted butter&lt;/li&gt;
  &lt;li&gt;150&amp;nbsp;g caster sugar&lt;/li&gt;
  &lt;li&gt;2 large eggs&lt;/li&gt;
  &lt;li&gt;Half tsp vanilla extract&lt;/li&gt;
  &lt;li&gt;50&amp;nbsp;g walnuts, chopped&lt;/li&gt;
  &lt;li&gt;250&amp;nbsp;g self-raising flour&lt;/li&gt;
  &lt;li&gt;Pinch of salt&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pre-heat oven to 180&amp;nbsp;°C. Lightly butter a 25x10&amp;nbsp;cm loaf
  tin. Cream butter and sugar together until smooth and pale.&lt;/p&gt;

&lt;p&gt;Add eggs one at a time, beating well.  Fold in mashed bananas,
  vanilla and walnuts. Sift in flour and salt and fold in.&lt;/p&gt;

&lt;p&gt;Spoon mixture into loaf tin, and bake for one hour or until a knife
  pushed into centre of cake comes out dry.  Cool in tin for at least
  20&amp;nbsp;min before turning out.&lt;/p&gt;

&lt;p&gt;My &lt;a href='http://www.peter-b.co.uk/blog/archive/2009_07_01_archive.html'&gt;chocolate
  brownies&lt;/a&gt; have also been popular recently, this time with the
  &lt;a href='http://www.surreyclimbs.co.uk/'&gt;University of Surrey
  Mountaineering Club&lt;/a&gt;!&lt;/p&gt;

    &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-4257058739345403506?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=4257058739345403506' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/4257058739345403506'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/4257058739345403506'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2010/03/banana-and-walnut-cake.html' title='Banana and walnut cake'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-4373117081599280978</id><published>2010-02-20T00:20:00.001Z</published><updated>2010-02-20T00:20:47.638Z</updated><title type='text'>GTK+ no longer supports Windows, apparently</title><content type='html'>
    &lt;div xmlns='http://www.w3.org/1999/xhtml'&gt;


&lt;p&gt;When writing computer programs, I try to ensure that they are
  portable enough to run on as many different platforms as possible
  without modifying the source code.  This becomes tricky when I'm
  writing in C and I want to provide a vaguely-modern-feeling user
  interface.  Since about 2006, I've relied
  on &lt;a href='http://www.gtk.org/'&gt;GTK+&lt;/a&gt;, the basis of
  the &lt;a href='http://www.gnome.org/'&gt;GNOME&lt;/a&gt; desktop environment,
  as my GUI library of choice. A good example of a piece of GTK+-based
  software for which I'm a member of the development team is
  the &lt;a href='http://www.gpleda.org/'&gt;gEDA project&lt;/a&gt;, a collection
  of tools for electronics design.&lt;/p&gt;

&lt;p&gt;One of the attractions of GTK+ for me has always been its ability
  to be used on both X Window System-based operating systems
  (e.g. Linux and BSD) and on Microsoft Windows. Unfortunately, it
  seems that Windows support has now been discontinued.&lt;/p&gt;

&lt;p&gt;Back in September, GTK+ 2.18 was released.  Unfortunately, it
  contained
  &lt;a href='https://bugzilla.gnome.org/show_bug.cgi?id=598299'&gt;a large
  regression&lt;/a&gt; which has caused some headaches for people working
  with GTK+ on the Windows platform (essentially, GTK+ applications
  would be completely unusable in some cases). Furthermore, a rewrite
  of some core GTK+ code inbetween 2.16 and 2.18 left the GTK+ on
  Windows infested with a host of other minor but annoying bugs.&lt;/p&gt;

&lt;p&gt;Now, what normally happens when an Open Source program upon which
  literally thousands of applications and millions of users depend has
  a major stable release containing a large regression on one of the
  major supported platforms?  Well, in &lt;em&gt;most&lt;/em&gt; such cases, the
  software's developers figure out a workaround as quickly as possible
  and make sure that those affected know about it, and then make haste
  to track down the source of the bug, fix it, test the fix, and issue
  a point release or set of patches with which their users can obtain
  a working version.&lt;/p&gt;

&lt;p&gt;Apparently not so in the case of GTK+.  Four months later, GTK+
  2.18.x is still pretty much unusable on Windows, and the general
  consensus is to use 2.16.x. Dominic Lachowicz, a GTK+ developer,
  has is still warning people not to use 2.18.x on Windows:&lt;/p&gt;

&lt;blockquote&gt;Look before you leap. GTK 2.18 on Windows is very
  buggy.&lt;/blockquote&gt;

&lt;p&gt;The attitude of the maintainer of the Windows port, Tor Lillqvist,
  has been quite alarming. In comments on the GNOME bugtracker, he
  gave no impression of any intention of resolving the issues himself,
  saying:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;You want ot use some new API present only in 2.18?
    Please then consider helping in actually debugging and fixing the
    problems in GTK+ 2.18 on Windows.&lt;/p&gt;
  &lt;p&gt;... perhaps you should just use the version of software as it was
    before the "introduction" of the bug? I mean, nobody promised you
    there would be any updates of Windows-specific functionality, or
    otherwise, in GTK+, right? So just use GTK+ as it was before
    "somebody broke it".&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;It's becoming distressingly clear that there is no-one in the
  current GTK+ development team with any particular commitment to
  keeping the Windows support in working order. Furthermore, it seems
  clear to me that the hostile and confrontational attitude of
  people like Tor will tend to drive away any new developers
  interested in taking the work on. It's already hard enough to get
  patches into GTK+ as it is -- even complete and tested patches tend
  to hang around in the GNOME bugtracker for weeks or months before
  being dealt with.&lt;/p&gt;

&lt;p&gt;Going forward, I think that I'll need to find an alternative set of
  libraries that I can use for cross-platform GUI programming and get
  a well-integrated 'look and feel' with.
  The &lt;a href='http://qt.nokia.com/'&gt;Qt&lt;/a&gt; toolkit has a good
  reputation for documentation and support, but doesn't seem to
  support applications written in C.  Are there any other alternatives
  I've missed?&lt;/p&gt;

    &lt;/div&gt;
  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-4373117081599280978?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=4373117081599280978' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/4373117081599280978'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/4373117081599280978'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2010/02/gtk-no-longer-supports-windows.html' title='GTK+ no longer supports Windows, apparently'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-7314998164631008527</id><published>2010-02-01T08:49:00.005Z</published><updated>2010-02-01T09:04:08.794Z</updated><title type='text'>Project Postcard</title><content type='html'>&lt;p&gt;I recently wrote a blog posting for the Pirate Party UK website about my latest publicity initiative: &lt;a href="http://www.pirateparty.org.uk/blog/2010/jan/29/project-postcard/"&gt;Project Postcard&lt;/a&gt;!&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;The election is fast approaching, and the time has come to really press on with raising our profile.  All our members need to be doing their part if we're going to make an impact on the UK political landscape. I personally have been aiming to do something meaningful &amp; constructive for the party every day -- and I recommend to you all to make a similar commitment. Even little things can make a real difference.&lt;/p&gt;
&lt;p&gt;One way you might be able to help is to get involved with my 'Project Postcard' initiative. I'm shortly going to be ordering a few thousand professionally-produced postcard-like flyers, printed with information on who we are and what we stand for, as well as details of how to find out more.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Read &lt;a href="http://www.pirateparty.org.uk/blog/2010/jan/29/project-postcard/"&gt;the full article on the PPUK blog&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-7314998164631008527?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=7314998164631008527' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/7314998164631008527'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/7314998164631008527'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2010/02/project-postcard.html' title='Project Postcard'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-721186074571242901</id><published>2009-11-10T07:41:00.003Z</published><updated>2009-11-10T08:04:31.404Z</updated><title type='text'>From the ridiculous to the... even more ridiculous?</title><content type='html'>&lt;p&gt;I've been following the progress of &lt;em&gt;In Re Bilski&lt;/em&gt; before the US Supreme Court, because it's got the potential to set the rules for business method (and thus software) patents for the next few years.&lt;/p&gt;

&lt;p&gt;Unfortunately, it seems that lawyers' view of what constitutes a "good" patent has hit a new and hilarious low. Take this extract from the oral arguments (&lt;a href="http://www.groklaw.net/article.php?story=20091109191422928"&gt;thanks to Groklaw for pointing it out&lt;/a&gt;):&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;JUSTICE KENNEDY: But it would be different, it seems to me, than what you are -- let's assume you can't patent an alphabet. I assume that is true. And you can take an alphabet to make beautiful words, and -- and so forth. You -- you want to say that these -- these electronic signals can be used in a way just like the alphabet can be used. And many of the scientific briefs say that their process is different, that they are taking electronic signals and turning them into some other sort of signal. But that's not what you are doing.&lt;/p&gt;

&lt;p&gt;MR. JAKES: That may be, but those signals could also be transmitted. On -- on your question about the alphabet you said look at the Morse claim 5, which was an alphabet to Morse Code. That's exactly what it was.&lt;/p&gt;

&lt;p&gt;CHIEF JUSTICE ROBERTS: So you reject -- you reject the substitute. You think you can patent an alphabet because it is a process of forming words.&lt;/p&gt;

&lt;p&gt;MR. JAKES: It could be, yes. &lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;In what world does this seem like a sane and reasonable way for patentability rules to evolve?&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-721186074571242901?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=721186074571242901' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/721186074571242901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/721186074571242901'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2009/11/from-ridiculous-to-even-more-ridiculous.html' title='From the ridiculous to the... even more ridiculous?'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5144379.post-3214632574227438666</id><published>2009-11-05T12:23:00.002Z</published><updated>2009-11-05T12:36:59.019Z</updated><title type='text'>ACTA: write to them!</title><content type='html'>&lt;p&gt;I've now written to both the Green MEP in my region, Caroline Lucas, and my MP, Humfrey Malins.&lt;/p&gt;

&lt;p&gt;My e-mail to Caroline Lucas was fairly straightforward to write. Firstly, she's an MEP, and thus European-level matters are more directly relevant to her interests. Additionally, the Commission have been ignoring direct calls, by MEPs, lead by the Green Party, for more transparency in ACTA, so I know that she already agrees that there's a problem.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;Dear Dr. Lucas,&lt;/p&gt;

&lt;p&gt;In December 2008, lead by the Green Party, the European Parliament adopted
a resolution regarding ACTA which:&lt;/p&gt;

&lt;blockquote&gt;"... Calls on the Commission and the Member States to negotiate ACTA under
conditions of the utmost transparency towards EU citizens, especially with
regard to the definitions of the terms "counterfeiting" and "piracy" and
the criminal sanction measures foreseen; takes the view that the social
impact of the agreement as well as the impact on civil liberties must be
assessed; supports the establishment of a task force to examine the
implementation of the agreement, by promoting this subject in dialogue
between the European Union and third countries and as part of cooperation
measures with those countries..." [P6_TA(2008)0634]&lt;/blockquote&gt;

&lt;p&gt;Furthermore, in March 2009, the Parliament and Council adopted a Regulation
that required that:&lt;/p&gt;

&lt;blockquote&gt;"In accordance with Article 255(1) of the EC Treaty, the Commission should
immediately make all documents related to the ongoing international
negotiations on the Anti-Counterfeiting Trade Agreement (ACTA) publicly
available. [Am 109]" [P6_TA-PROV(2009)0114]&lt;/blockquote&gt;

&lt;p&gt;Nevertheless, many months later, the ACTA text under discussion is still
being discussed behind closed doors, without the opportunity for review or
discussion by those whom it will affect if adopted. I would greatly
appreciate an explanation as to why this is, and what the Parliament, the
Green Party and you yourself are currently doing to address this.&lt;/p&gt;

&lt;p&gt;Yours sincerely,

&lt;p&gt;Peter Brett&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Writing to Humfrey Malins was more challenging. Firstly, European Commission-level negotiations aren't something that the Commons has any real direct influence on. However, the fact that the Baroness of Uphallow is the European Commissioner for Trade provided a way to demonstrate the ACTA negotiations' direct relevance.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;Dear Humfrey Malins,&lt;/p&gt;

&lt;p&gt;The UK, as part of the European Commission, is currently in the process
of negotiating the plurilateral Anti-Counterfeiting Trade Agreement.&lt;/p&gt;

&lt;p&gt;This process has been concealed behind a veil of utmost secrecy,
despite repeated demands by the European Parliament and Council for
greater transparency (see: P6_TA(2008)0634 and P6_TA-PROV(2009)0114).
Only a rough outline of the structure of the proposed treaty is
available to the billions of people who will be affected by its
provisions.  I do not believe that, in the case of a trade treaty, such
secrecy serves the public interest. The quality and fairness of the
results of the process can only be improved by allowing the people in
whose name the treaty is being negotiated to see and discuss the actual
provisions being suggested.&lt;/p&gt;

&lt;p&gt;I have already written to my MEPs, but the Commission has made it quite
clear that they intend to continue to ignore the European Parliament's
position on this issue.  Catherine Ashton is the UK Commissioner and
holder of the Commission's Trade portfolio, and as such is responsible
for the Commission's role in the ACTA negotiations. (It is interesting
to note that the Baroness of Upholland has no background in trade
issues and has never been elected to public office.)&lt;/p&gt;

&lt;p&gt;Would you be willing to ask the Prime Minister to direct Baroness
Ashton to encourage the EU ACTA delegation to open the process to
public scrutiny, please?  It seems to me this would greatly serve the
public interest.&lt;/p&gt;

&lt;p&gt;Yours sincerely,&lt;/p&gt;

&lt;p&gt;Peter Brett&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Hopefully I'll get some useful and timely replies. We'll see!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5144379-3214632574227438666?l=blog.peter-b.co.uk' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5144379&amp;postID=3214632574227438666' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/3214632574227438666'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5144379/posts/default/3214632574227438666'/><link rel='alternate' type='text/html' href='http://blog.peter-b.co.uk/2009/11/acta-write-to-them.html' title='ACTA: write to them!'/><author><name>Peter</name><uri>http://www.blogger.com/profile/13507691713687465296</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
