<?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-4426441845073804938</id><updated>2012-02-16T20:20:54.634+01:00</updated><category term='xml'/><title type='text'>Glooping</title><subtitle type='html'>Practically liberating floop</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.gloop.iocl.org/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4426441845073804938/posts/default'/><link rel='alternate' type='text/html' href='http://blog.gloop.iocl.org/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Andreas Krey</name><uri>http://www.blogger.com/profile/18011171943440483489</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://images.iocl.org/ak.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4426441845073804938.post-6585666156738241230</id><published>2007-03-13T10:24:00.000+01:00</published><updated>2007-03-13T11:05:53.700+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><title type='text'>They all say - nothing</title><content type='html'>XML is the eXtensible Markup Language, and obviously is the current kittchen sink of communication. Its purpose is to mark up text, to say 'this part is such-and-such, and that part is a order number'. But if you came here you knew that anyway.
&lt;p&gt;
Now, there is a strange tendency. XML is used everywhere, and most files containing XML have a peculiar property: Remove the &amp;lt;tags&amp;gt;, and they contain - nothing. There isn't anything but white space that is 'marked up'. Instead the tags and their attributes represent &lt;i&gt;all&lt;/i&gt; the relevant data. And I wonder why they still don't do away with the &amp;lt;&amp;gt; and use a notation that is actually up to the task. After all, the XML syntax is just so it &lt;i&gt;can&lt;/i&gt; be embedded in marked-up text. It's like using a hammer to drive in a screw, just for the lack of a standardized &lt;a href="http://www.json.org/"&gt;screwdriver&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4426441845073804938-6585666156738241230?l=blog.gloop.iocl.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.gloop.iocl.org/feeds/6585666156738241230/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4426441845073804938&amp;postID=6585666156738241230' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4426441845073804938/posts/default/6585666156738241230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4426441845073804938/posts/default/6585666156738241230'/><link rel='alternate' type='text/html' href='http://blog.gloop.iocl.org/2007/03/they-all-say-nothing.html' title='They all say - nothing'/><author><name>Andreas Krey</name><uri>http://www.blogger.com/profile/18011171943440483489</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://images.iocl.org/ak.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4426441845073804938.post-8465230894879368899</id><published>2006-11-11T21:29:00.000+01:00</published><updated>2006-11-11T22:11:33.950+01:00</updated><title type='text'>No keywords</title><content type='html'>Ever wondered why languages have keywords? Well, they even fight over it -- some smalltalk proponent argued that smalltalk having just five keywords is way better than ruby having thirtysome. But special cases are usually only zero, one or infinity, and in this case &lt;i&gt;one&lt;/i&gt; is out, too.
&lt;p&gt;
So indeed a language should at best not have any keywords at all. But the only that manage to do so are from the lisp family. In the others you sometimes get the really strange error. In C it is perfectly legal to say &lt;code&gt;int class;&lt;/code&gt;, and thus the X11 people did exactly that (in a structure declaration). Use that header from C++, and you get a rather unexpected syntax error. A reserved keyword is not an identifier, and thus raises the syntax error. Also the C++ community continues inventing new keywords while C goes to strange things like &lt;code&gt;long long&lt;/code&gt; to avoid that.
&lt;p&gt;
The solution is to make keywords into regular entries in the global symbol table with special values. That way any other scope could use any identifier it likes without fear of clashes with esoteric or future 'keywords'. There is one disadvantage: Parsing is affected by semantic analysis, but then that is no news, remember &lt;code&gt;typedef&lt;/code&gt; which is explicit in C and implicit in C++ class declarations. But then, since gloop is to have macros, this is no additional disadvantage.
&lt;p&gt;
And to answer the question: Keywords are most easily handled directly as special tokens, and they have been invented waaay before the concept of namespace pollution.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4426441845073804938-8465230894879368899?l=blog.gloop.iocl.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.gloop.iocl.org/feeds/8465230894879368899/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4426441845073804938&amp;postID=8465230894879368899' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4426441845073804938/posts/default/8465230894879368899'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4426441845073804938/posts/default/8465230894879368899'/><link rel='alternate' type='text/html' href='http://blog.gloop.iocl.org/2006/11/no-keywords.html' title='No keywords'/><author><name>Andreas Krey</name><uri>http://www.blogger.com/profile/18011171943440483489</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://images.iocl.org/ak.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4426441845073804938.post-3949797838757072113</id><published>2006-10-31T20:09:00.000+01:00</published><updated>2006-11-11T22:12:45.557+01:00</updated><title type='text'>The human compiler, #1</title><content type='html'>At it again... You want to get a sum over a subset of objects in a list. You &lt;i&gt;don't&lt;/i&gt; want to iterate over the objects explicitly (as in &lt;tt&gt;for (ob = first_obj (list); ob; ob = next_obj (ob))&lt;/tt&gt;), because that gets pretty annoying pretty soon, and also becomes interesting when you have to change that a bit for an explicit iterator state object.
&lt;p&gt;
Instead there is a function &lt;tt&gt;iter_list&lt;/tt&gt; which calls a function of your for each object in the list, completely hiding the actual process of iteration. Unfortunately, now you need somehow pass your context into the callback function, and, being in C, &lt;tt&gt;iter_list&lt;/tt&gt; accepts a separate parameter called &lt;tt&gt;userdata&lt;/tt&gt; that it just passes to the callback for your use. Thus you do:
&lt;pre&gt;struct ctx {
  int sum;
  char *pref;
};
int cb (obj_t *obj, void *userdata) {
  struct ctx *cx = userdata;
  if (match (obj-&gt;name, cx-&gt;pref)) {
    sum += obj-&gt;count;
  }
}
int sum_prefixed (oblist_t *list, char *prefix) {
  struct ctx C;
  C.pref = prefix;
  C.sum = 0;
  iter_list (list, cb, &amp;C);
  return C.sum;
}&lt;/pre&gt;Not quite amusing, because C does not have any local functions with lexical scoping. In a better language one could write
&lt;pre&gt;int sum_prefixed (oblist_t *list, char *prefix) {
  int sum = 0;
  int cb (obj_t *obj) {
    if (match (obj-&gt;name, pref)) {
      sum += obj-&gt;count;
    }
  }
  iter_list (list, cb);
  return sum;
}&lt;/pre&gt;The local function &lt;tt&gt;cb&lt;/tt&gt;has access to the variables surrounding its own definition. In essence the compiler now does what we did (pattern-like) above, by hand. To be even able to do the hand-trick, &lt;tt&gt;iter_list&lt;/tt&gt; needs to have the third, pass-through, parameter; in the version where local functions are available this is no longer needed.
&lt;p&gt;
In fact the local function above works in Gnu C as shown as an language extension.
&lt;p&gt;
The next simplification would be to allow the function body directly in the place where it is needed, instead of defining a function and then using it's name:
&lt;pre&gt;int sum_prefixed (oblist_t *list, char *prefix) {
  int sum = 0;
  iter_list (list, int (obj_t *obj) {
    if (match (obj-&gt;name, pref)) {
      sum += obj-&gt;count;
    }
  });
  return sum;
}&lt;/pre&gt;The syntax gets a bit tricky here, but this is already very close to a form where &lt;tt&gt;iter_list&lt;/tt&gt; looks like a real loop header construct. Alas, &lt;tt&gt;break&lt;/tt&gt; won't work yet.
&lt;p&gt;
But since I have to use C in this project, I need to partially do the job of a compiler, and put down &lt;i&gt;patterns&lt;/i&gt; again and again. Also, some languages spare me of actually declaring the type signature of the anonymous function and derive it from type of the argument for which it is used. That is called type inference, and in Java you would want it all the time, &lt;tt&gt;hypo.Wouldnt w = new hypo.Wouldnt ()&lt;/tt&gt; you?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4426441845073804938-3949797838757072113?l=blog.gloop.iocl.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.gloop.iocl.org/feeds/3949797838757072113/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4426441845073804938&amp;postID=3949797838757072113' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4426441845073804938/posts/default/3949797838757072113'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4426441845073804938/posts/default/3949797838757072113'/><link rel='alternate' type='text/html' href='http://blog.gloop.iocl.org/2006/10/human-compiler-1.html' title='The human compiler, #1'/><author><name>Andreas Krey</name><uri>http://www.blogger.com/profile/18011171943440483489</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://images.iocl.org/ak.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4426441845073804938.post-7633123294218085190</id><published>2006-09-30T00:18:00.000+02:00</published><updated>2006-09-30T00:24:53.720+02:00</updated><title type='text'>Thou shalt google first</title><content type='html'>I just tried to see whether google would find this blog yet, only to find out that &lt;i&gt;gloop&lt;/i&gt; has quite another meaning already. A meaning rather close to the current state of affairs in popular programming languages, however. So I stay with the blog name.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4426441845073804938-7633123294218085190?l=blog.gloop.iocl.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.gloop.iocl.org/feeds/7633123294218085190/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4426441845073804938&amp;postID=7633123294218085190' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4426441845073804938/posts/default/7633123294218085190'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4426441845073804938/posts/default/7633123294218085190'/><link rel='alternate' type='text/html' href='http://blog.gloop.iocl.org/2006/09/thou-shalt-google-first.html' title='Thou shalt google first'/><author><name>Andreas Krey</name><uri>http://www.blogger.com/profile/18011171943440483489</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://images.iocl.org/ak.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4426441845073804938.post-310299572314906141</id><published>2006-09-16T21:57:00.000+02:00</published><updated>2006-09-16T22:19:17.931+02:00</updated><title type='text'>Gloop, the universe and everything?</title><content type='html'>I don't know that this blog is going to turn out to be. But the
name is a reference to the three programming languages &lt;tt&gt;bloop&lt;/tt&gt;,
&lt;tt&gt;floop&lt;/tt&gt;, and &lt;tt&gt;gloop&lt;/tt&gt; that Douglas Hofstadter introduced
to illustrate a few points in computability.&lt;br/&gt;&lt;br/&gt;

&lt;tt&gt;bloop&lt;/tt&gt; is especially designed not to be turing-complete,
and he removes one constraint to create &lt;tt&gt;floop&lt;/tt&gt; which
&lt;i&gt;is&lt;/i&gt;. That one still is unable to compute every imaginable
function  and thus he continues to &lt;tt&gt;gloop&lt;/tt&gt;, only to confront
us with the fact that there is no such thing. No programming language
can be more powerful that &lt;tt&gt;floop&lt;/tt&gt;.&lt;br/&gt;&lt;br/&gt;

From the theoretical point of view, that is. In practice there is
a big difference in how much effort you need to express in different
languages what you want the computer to do. Programming is much
about abstracting away repeating chores, and it is astonishing how
much of those &lt;i&gt;can't&lt;/i&gt; be automated in the popular languages
of the day.&lt;br/&gt;&lt;br/&gt;

By now I am actively suffering from the fact that there are so many
things that a good language would make easier but such language either
don't exist or aren't reasonable to use in the field I need them.&lt;br/&gt;&lt;br/&gt;

Closures, anonymous functions and proper lexical scoping are the
things I would like to play with. But a proper macro system is the
one thing that would really spare me a lot of tedious work.

To be able to toy with these concepts I am hacking a language that
is more or less going to be a (im)proper java: static typing with local
functions and closures, and most importantly with means to extend the
parser and to write macros that can use the full power of the language.&lt;br/&gt;&lt;br/&gt;

One additional aspect is to make the virtual machine fully persistent
meaning that it can simply resume execution of a program after the
VM has terminated for some external reason.&lt;br/&gt;&lt;br/&gt;

So this language and other linguistical musings will be the
topic of this blog. I'm probably not going to rant about aspherical
lenses for glasses here.&lt;br/&gt;&lt;br/&gt;

And no, I don't have the compiler ready. At the moment I have a very
basic lexer and parser. The third version, actually. I started with
C++ (ugly), then Ruby (good), then Nice (not bad). The last try is
partly because the Ruby version was already two months ago and partly
because I have hopes that the Nice version is more easily translated
into the target language itself. Next job is to figure out a VM and
execution model.&lt;br/&gt;&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4426441845073804938-310299572314906141?l=blog.gloop.iocl.org' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.gloop.iocl.org/feeds/310299572314906141/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4426441845073804938&amp;postID=310299572314906141' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4426441845073804938/posts/default/310299572314906141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4426441845073804938/posts/default/310299572314906141'/><link rel='alternate' type='text/html' href='http://blog.gloop.iocl.org/2006/09/gloop-universe-and-everything.html' title='Gloop, the universe and everything?'/><author><name>Andreas Krey</name><uri>http://www.blogger.com/profile/18011171943440483489</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://images.iocl.org/ak.jpg'/></author><thr:total>0</thr:total></entry></feed>
