Older blog entries for graydon (starting at number 81)

jdybnis: I think the cheeky answer is to be found in r5rs wrt. the disjointness of types. however, evaluation as boolean is polymorphic, such that anything which is not #f is coerced to #t. so your code can be written as:

(define (breadth . trees)
 (or trees
  (cons (map car trees) 
   (apply breadth 
    (apply append (map cdr trees)))) 
  '()))

but the perhaps-valid question you could then ask is: why isn't '() coerced to #f, and conversely why there isn't a coerce-to-list form for booleans. dunno. MIT scheme treats them the same, so perhaps they didn't see the logic in it either.

creepers!
#!/usr/bin/scm  
 
(define (f str)  
  (lambda (them)  
    (let loop ((rest them) (ls (string->list str))) 
      (if (pair? ls)  
          (begin (write-char (car ls)) 
                 (loop (call-with-current-continuation  
                     (lambda (us) (rest us)))  
                    (cdr ls))) 
          (newline))))) 
                 
((f "Js nte ceeWnae")(f "utAohrShm anbe")) 
^D

04:27:13 graydon> ./f.scm Just Another Scheme Wannabee >

ModernRonin raised the "how could C be improved" issue (without sacrificing its simplicity and minimalism, I assume), and the language geek in me can't resist commenting:

  1. hygenic macros or at least inline functions (some in c99)
  2. explicit sized integer types (in c99)
  3. namespaces & imports rather than #include
  4. pointer restrictions (some in c99)
  5. runtime-variable length arrays without resorting to alloca (in c99)
  6. a backtick operator
  7. a jump convention without resorting to setjmp/longjmp
mars retreats

as some of the vegetarians in the audience may know, putting soy milk in a good strong cup of coffee often results in suboptimal results: the soy curdles and you get a sort of splotchy, aesthetically displeasing fluid resembling miso. rather than accept her fate however, my 1337 protein-haxx0r girlfriend stared at it, scratched her head, pulled out some baking soda, added a pinch and stirred. the pH raised, the globular proteins dissociated, and the coffee returned to being creamy.

other stuff: binary decision diagrams are extremely cool, as is <bigwig>. found a cool archive of more noam chomsky than you could shake a stick at, and saw some films: oh brother where are thou (good), do the right thing and bamboozled (spike lee double bill, ++good), state and main (good), and crouching tiger (turbo-good).

the 187 skillz

Been playing with modular monadic interpreters and compilers recently. The monad keeners are really clever: the idea is to separate out "facets" of a language processor (a la action semantics) into separate monads, such that (if you get the liftings right) you can do a modular proof of your rewrite semantics for that facet irrespective of the other facets you may have enabled. This is cool: you can develop a working call/cc system or lambda abstraction or calling convention in isolation, test it out, then just sorta graft it into an existing compiler / interpreter. The math gets a little ghastly but it's miles better than plain denotational semantics.

Monads are one of those things like pointers or closures. You bang your head against them for a year or two, then one day your brain's resistance to the concept just breaks, and in its new broken state they make perfect sense. I've only constructed a UA parser and 2-level interpreter at the moment but the fact that I could do so in a couple pages of haskell is rather amazing. Parsec makes Bison look like a sad joke.

er, um. otherwise I've been on vacation. watched a lot of television, ate a lot of waffles, and read a lot of ACL2 examples. went for walks in the snow with frances, played with baby rissa, slept, perused the various available open cores, listings for FPGA's on PCI cards (and DIMMS!) read up on current leftist media and browsed the libstdc++ design notes.

a weird few weeks of "everything old is new again": playing with computer music synthesis (haskore and its interface to csound), futzing around with proof general, common lisp and most interestingly ACL2, and inspecting the current round of assemblers, JITs, assembler-makers and simulators.

pleasantly surprised by the quality of some of this stuff. after a few months of digging through refuse in freshmeat (not to mention my own src/ dir :) I was getting to really loathe software.

and amidst this mad year, I didn't even notice that dmoz is bigger than yahoo. congrats, dmoz.

big jim!

Suddenly became interested in FPGAs after attending some lectures on high level circuit design and reading up on the free tools for doing EDA. So much to play with...

Fascinating reading from the same professor: a proposal for unification of boolean and number algebras and a formalization of time and space. What impresses me most about this stuff is the attention to simplicity and readability; something unfortunately ignored by far too much literature on formal methods.

ObTalkOrigins: responsible teachers of either Evolutionary Biology or the Book of Genesis should avoid over-extending their subject to a complete theory of origins. Each offers something to chew on, neither is enough to finish the job.

flip a coin

Saddened by the loss of mathworld. I once attempted to mirror it, but eric's atitude was that it was his "property" (never mind that all the material was discovered by others) and that even people acting in the public interest ought not to propagate his writings, so he outright banned any IPs which crawled more than a particular portion of the site.

I've noticed this thread quite a bit recently: academic people are often as reluctant as corporate people to hand over their work to the public without putting strings on it. Such strings run the gamut from "non-commercial use only" to outright denial of useful work. I've tried arguing the point with a few groups making valuable mathematical software, and have been astonished to hear the argument "why should someone else benefit from my work?"

Why on earth is someone in research, in a publicly funded institution of learning, if they do not expect others to benefit from their work? Are they just there to show off, live the life of a poor researcher, grind theoretical axes with their colleagues? It seems a bit silly given the amount of public information is required to get a good education in the first place.

Oh well. We definitely need to replace mathworld; I fear the UberWikis of the world may not adequately support editing mathematical notation inline, and that some sort of blend of HTML renderings and LaTeX source might be in order. Recent positive impressions of Hevea spring to mind. I somehow doubt that MathML will be able to revive itself. Integrating mathematical semantics and mathematical typesetting seems to me like a fool's errand, as people will always be discovering new branches of mathematics, writing software to explore them, and inventing notations to describe them. I would be perfectly happy to visit a page containing a very good Hevea rendering of some explanatory LaTeX, a link to some PARI or Maxima code implementing the concept, and perhaps a "fetch LaTeX/DVI" button.

wen: to dodge the XML issue entirely and focus on the issue of pseudocode, all I can say is that programming language semantics are a lot more complex than you give them credit for. It is not at all trivial to translate "any" language to "any" other, despite our ability to prove the existence of such translations. A translation will range from a simple statement-for-statement rewrite to an unrecognizable mass of supporting code necessary to preserve meaning. In any event, the idiomatic clarity of code written by a human (which is only moderate at the best of times) is likely to vanish, rendering the main purposes of a high level language (communication and maintainability) moot.

for the other novice haskellers in the audience:

haskell supports equational reasoning, which means that the meaning of a program is not changed if you substitute a symbol for its definition, or vice-versa. this is something which I had only sort of appreciated the importance of, insofar as it lets you do neat stuff with fold and map. of course it goes much deeper than that, but I never knew how much.

The algebra of programming is a beautiful introduction (by the algebra of programming research group in oxford) to the advantage of equational reasoning about programs. it develops just enough category theory to frame functional programming in, and presents a purely equational, pen-and-paper approach to deriving programs which solve combinatorial optimization problems.

conventional program "design" (whiteboards full of boxes and arrows) looks rediculous when shadowed by the results in this book. after proving the validity of a given set of transformations which are legal in an equational reasoning framework, problem definitions are simply rewritten as code which solves the problem. it's eerie; the sort of stuff you always hoped would be possible but seemed to lie forever beyond the normal material on algorithms.

cmm: assume for argument's sake reproduction rate in canada was steady self-replacement and in india it was a yearly doubling function. furthermore assume the canadians make up C worth of the current world population P, and indians I worth of it.

pick some year in the future, N. the world population, if canadians continue to reproduce, is (2^N)*IP + CP. if canadians halt their reproduction, the world population is (2^N)*IP. this is less. it's still lots, but it's less.

lilo is implying that if we stake out our territory we can lock the problems of india inside india and keep north america underpopulated. this assumes both that indians are culturally incapable of change, and that north americans are doing a better custodial job with the continent than indians would. I don't believe either of those sentiments to be true.

furthermore the whole line of reasoning reeks of fatalism. if something can be done in the near and medium term, it is the best we are capable of and we should not shy away from it simply because in some possible future our work may be erased. everyone dies eventually, but we do not kill ourselves because of that knowledge.

lilo: you know what, never mind. I don't actually care enough about political systems to pick apart a libertarian "everyone is educated and wise, so we need no government" scenario. all I suggested is that we do less stuff. don't take the suggestion to be a declaration of fascist policy-making. it's a suggestion, like "you should cut your hair" or "you should try this pudding". if you don't agree with the reasoning, fine. the pudding tastes bad to you. enjoy your lifestyle.

72 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!