tag:blogger.com,1999:blog-297690232009-07-04T11:31:44.635ZTiago, O IrrepupávelTiago Cogumbreiro loves to talk about Python, GNOME, web development, and Open Source; with a bit of nonsense here and there.Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.comBlogger133125tag:blogger.com,1999:blog-29769023.post-77105042623236218232009-07-02T10:47:00.005Z2009-07-02T16:20:56.983ZAn applet for MIL and the simply typed π-calculus compiler<p> In an effort to showcase my <acronym title="Master of Science">MSc</acronym> work, I have developed an applet that contains the &pi;-calculus compiler along with the MIL interpreter. You can try out either MIL our the simply-typed &pi;-calculus and run it online. Our article about <a href="http://dx.doi.org/10.1016/j.entcs.2009.06.004">compiling the &pi;-calculus into a multithreaded typed assembly language</a> is an useful reference.</p> <p style="text-align:center;"> <a href="http://gloss.di.fc.ul.pt/mil/applet/"><img src="http://gloss.di.fc.ul.pt/mil/applet.png" alt="Try MIL and the pi-calculus compiler on-line!" /></a> </p> <p>The &pi;-calculus consists of processes that run concurrently—you may read processes as tasks or threads, although they sit at a much higher level. The simplest process is the inactive one that finishes, we represent it by a zero <code>0</code>. The basis of the &pi;-calculus is communication; it is so important that the fundamental step of computation is the communication of sequences of values (integers, strings, and channels). Processes synchronize (and communicate) by message-passing, using channels. To send a message <code>10</code> through a channel <code>x</code> we write the output process <code>x&lt;10></code>. To receive a message through a channel <code>x</code> and store it in a name <code>y</code> that is visible in process <code>P</code> we write the input process <code>x(y).P</code>, notice that process <code>P</code> is not a variable, it must be replaced with an actual process, like the inactive process <code>0</code>. If we want to receive a message repeatedly, like a server does, we just write a bang (<code>!</code>) in front of an input process, for example <code>!x(y).P</code>. To execute process <code>P</code> in parallel with process <code>Q</code> we write the parallel process <code>P | Q</code>, or to remove ambiguity we may use parenthesis <code>(P | Q)</code>. To use a channel <code>x</code> in a process <code>P</code>, we must first declare it along with its type <code>T</code> by writing <code>new x:T P</code>. A type <code>T</code> is not a variable, it can be either an integer type <code>int</code>, a string type <code>str</code>, or a channel <code>^[T1,...,Tn]</code> (the parameters ranging from <code>T1,...,Tn</code> are a possibly empty sequence of types, like the empty channel type <code>^[]</code> or the channel that communicate two integers <code>^[int,int]</code>. Channels may themselves send channels, for example channel type <code>^[int,^[int]]</code> types channels that communicates two values, one of the integer type, another a channel that communicates integers. <p>A quick example of an echo server:</p> <pre> new echo:^[int,^[int]] ( !echo(x,y).y&lt;x> | new print:^[int] ( !print(m).printInt&lt;m> | echo&lt;10,print> ) ) </pre><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-7710504262323621823?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com0tag:blogger.com,1999:blog-29769023.post-59716619894648845402009-06-23T09:56:00.003Z2009-06-23T10:04:36.377Z“Compiling the π-calculus into a multithreaded typed assembly language” is published<p> After one year the article <a href="http://blog.irrepupavel.com/2008/05/accepted-in-places-08.html">I presented</a> in <a href="http://places08.di.fc.ul.pt/">PLACES '08</a> was published. </p> <cite> We extend a previous work on a multithreaded typed assembly language (MIL) targeted at shared memory multiprocessors, and describe the design of a type-preserving compiler from the π-calculus into MIL. The language enforces a policy on lock usage through a typing system that also ensures race-freedom for typable programs, while allowing for typing various important concurrency patterns. Our translation to MIL generates code that is then linked to a library supporting a generic unbounded buffer monitor, variant of Hoare's bounded buffer monitor, entirely written in MIL. Such a monitor shields client code (the π-calculus compiler in particular) from the hazardous task of direct lock manipulation, while allowing for the representation of π-calculus channels. The compiler produces type correct MIL programs from type correct source code, generating low-contention cooperative multithreaded programs. </cite> <p> Tiago Cogumbreiro, Francisco Martins, and Vasco T. Vasconcelos. <a href="http://dx.doi.org/10.1016/j.entcs.2009.06.004">Compiling the π-calculus into a multithreaded typed assembly language</a>. <i>ENTCS</i>, 241:57–84, 2009. </p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-5971661989464884540?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com0tag:blogger.com,1999:blog-29769023.post-16238697059893536892009-04-06T17:45:00.002Z2009-04-06T17:51:35.081ZProblemas com acentos usando Latex, Flyspell, ISpell e Emacs<p> Estive muito tempo com problemas na forma como o Emacs e o ISpell reconheciam as palavras portuguesas. Depois de muito escavar lá encontrei o <a href="http://natura.di.uminho.pt/~jj/pln/dot.emacs"><code>.emacs</code></a> do <a href="http://natura.di.uminho.pt/~jj/pln/pln.html">sítio oficial do dicionário português para ISpell</a>. Para corrigir, coloquem este código no vosso <code>.emacs</code>: </p> <pre> (custom-set-variables '(ispell-local-dictionary-alist (quote (("portugues" "[A-Za-zàèìòùÀÈÌÒÙáéíóúÁÉÍÓÚãõÃÕâêîôûÂÊÎÔÛçÇ]" "[^A-Za-zàèìòùÀÈÌÒÙáéíóúÁÉÍÓÚãõÃÕâêîôûÂÊÎÔÛçÇ]" "[-]" nil nil "~latin1" iso-8859-1) ("portutex" "[A-Za-z\\\\\\\\]" "[^A-Za-z\\\\\\\\]" "[---~`'^{}]" nil nil "~tex" iso-8859-1))))) </pre> <p>Isto é quase <a href="http://www.ascii-art.de/">arte ASCII</a>.</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-1623869705989353689?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com1tag:blogger.com,1999:blog-29769023.post-57446970080761597382009-04-01T22:18:00.002Z2009-04-01T22:29:59.049ZRedirecting to an external link/URL in Zope (and Plone)<p> Go to the <em>Zope Management Interface</em>. In <a href="http://plone.org/">Plone</a> click on Site Setup (on the upper left corner) and then under <em>Plone Configuration</em> click on <em>Zope Management Interface</em>. </p> <p> Next, create a content <em>Script (Python)</em> (select it in the drop-down widget in the upper left corner of the page). Select the name of the <strong>link</strong> of the origin of the redirection and click on <em>Add and Edit</em>.</p> <p>Add the following content:</p> <pre> # Import a standard function, and get the HTML request and response objects. from Products.PythonScripts.standard import html_quote request = container.REQUEST RESPONSE = request.RESPONSE #return context.REQUEST.RESPONSE.redirect("http://www.google.com/") return RESPONSE.redirect("http://www.google.com/") </pre> <p> This will redirect <code>http://YOURHOSTNAME/foo</code> (if you create the python script at the root of your Zope Management Interface named <em>foo</em>) and redirect it to <a href="http://www.google.com/">http://www.google.com/</a>. Could be easier (and fully accessible trough Plone's UI). </p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-5744697008076159738?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com0tag:blogger.com,1999:blog-29769023.post-46354436694603582192009-03-08T22:10:00.002-01:002009-03-08T22:17:19.125-01:00MiNEMA Winter School 2009I am going to attend <a href="http://www.cse.chalmers.se/minema2009/">MiNEMA Winter School</a>. Great oportunity to learn about <a href="http://en.wikipedia.org/wiki/Wireless_Sensor_Networks">wireless sensor networks</a> and to discover <a href="http://en.wikipedia.org/wiki/Gothenburg">Göteborg</a>.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-4635443669460358219?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com1tag:blogger.com,1999:blog-29769023.post-83105783825457994992009-02-18T01:08:00.002-01:002009-02-18T01:11:08.838-01:00World of Goo<p> I was amazed by the demo and had to buy the full game of <a href="http://www.worldofgoo.com/">World of Goo</a> (for Linux). I do not play a game in years, so this was really a urge I could not control ;-) The game cost me 16 euros. </p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-8310578382545799499?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com3tag:blogger.com,1999:blog-29769023.post-89207294936229936562009-02-04T01:21:00.006-01:002009-02-04T22:52:54.039-01:00Hindley/Milner Type Inference Algorithm implementated in Haskell (untested and naïve)<p> I do not program in Haskell in a couple of years. Today I needed to learn the <a title=" A theory of type polymorphism in programming" href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.67.5276">Hendley/Milner algorithm for type inference</a> and decided to implement it in Haskell. A far more interesting related blog post is one about <a href="http://www.defmacro.org/ramblings/lisp-in-haskell.html">“Writing A Lisp Interpreter In Haskell”</a>, by Slava Akhmechet. </p> <p> You can grab the (hardly tested) code, released under public domain, in Pastebin at <a href="http://pastebin.com/f7dede189">http://pastebin.com/f7dede189</a>. The Source Code Is The Documentation™. </p> <p>I can't stress enough the usefulness of <a href="http://en.wikipedia.org/wiki/Algebraic_data_type">algebraic data types</a> and declarative languages for creating compilers. But <i>alas</i>, I am still working with Java in my research projects.</p> <p> <b>Update:</b> Because I have somehow broken the indentation, I have taken the chance to re-upload the source code, while cleaning up some code. Added a nice link about interpreter implementation using Haskell.</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-8920729493622993656?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com0tag:blogger.com,1999:blog-29769023.post-88115002857156673722008-12-11T22:12:00.004-01:002008-12-11T22:33:02.212-01:00The π-calculus library chapter and literate programming<p>I finished the &pi;-calculus library implemented in MIL. I started working in the translation chapter. Meanwhile, An explanation I received cleared up some details I was having with programming recursive types in MIL. With the misconception corrected I can now proceed working on the paper.</p> <p>For my work on the paper I intend to clean up my pseudo-framework for doing <a href="http://en.wikipedia.org/wiki/Literate_programming">literate programming</a>, which enables the library described in the aforementioned chapter to be generated and then type-checked for errors. Make the code free from embarrassing errors.</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-8811500285715667372?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com0tag:blogger.com,1999:blog-29769023.post-70619402016384183052008-12-10T21:11:00.004-01:002008-12-10T21:30:56.182-01:00pi2mil, mil, and the thesis<p> I reimplemented the compiler from the &pi;-calculus into MIL (in Java). The only part that was not touched was the parsing. It took me two days to rewrite the type-checking and the compiler. My work was basically translating mathematical notation into Java. It is interesting to note how much code was <em>simplified</em> because the translation was formalized. Looking back, I had an over-engineered compiler. Now I have a much simpler implementation and a proof that it is compiling safely, preserving types.</p> <p>After the compiler, I worked on synchronizing the implementation of MIL with the latest paper we have been working on. This amounted to rewriting the pretty-printer and to adding support for some instructions and a few types. The test battery we have implemented helped making sure I wasn't breaking any type-checking rule. There are, however, some problems that need to be solved in implementing some of the new sub-typing rules, notably with recursive types.</p> <p>In this last week I have mostly programmed and haven't made significant progress in my thesis. We are working on a paper with a deadline due next week. But since I am waiting for some feedback to continue working on the paper, I have an opening to finish up the chapter on the &pi;-calculus library. I only have half of a section to review to finish the chapter, so I hope I finish it in this week.</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-7061940201638418305?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com0tag:blogger.com,1999:blog-29769023.post-3015898839383754752008-11-27T13:17:00.005-01:002008-11-27T13:54:20.109-01:00Summary of the last week<p> I have been studying <a href="http://en.wikipedia.org/wiki/Monitor_(synchronization)">monitors</a> for a section included in the chapter of the &pi;-calculus library. The obvious references are <a href="http://portal.acm.org/citation.cfm?id=361161">“Monitors: An Operating System Structuring Concept”</a> for Hoare-style monitors and <a href="http://www.cs.berkeley.edu/~brewer/cs262/Mesa.pdf">“Experience with Processes and Monitors in Mesa”</a> for Mesa-style monitors. I also found the chapter <a href="http://www.artima.com/insidejvm/ed2/threadsynch.html">“Thread Synchronization”</a> of the book “Inside the Java Virtual Machine” inspiring. My friend Neva made me realize that I was misusing terminology in my introduction to monitors. </p> <p> After concluding the section I moved along to the section on the implementation of queues in <a href="http://gloss.di.fc.ul.pt/mil">MIL</a>. There is a typing rule in MIL that is confusing me. Spent yesterday's afternoon reading <a href="http://books.google.pt/books?id=ti6zoAC9Ph8C&dq=types+and+programming+language&pg=PP1&ots=EzGgzKo-VD&source=bn&sig=7qHj2ez6HD90wfU_pSpaqtVHOuo&hl=pt-PT&sa=X&oi=book_result&resnum=4&ct=result">“Types and Programming Languages”</a>, just to understand that I need way more time to understand the chapter about the meta-theory of recursive types. The good part is that I found out that my chapter explaining MIL is very superficial. The bad part is that I have to invest more time to make it deeper. Today I plan on rewriting most of the text included in the queues section.</p> <p> Yesterday I have also worked on a new project (another compiler). We are using <a href="http://sablecc.org/">SableCC</a> for the parser and for the <a href="http://en.wikipedia.org/wiki/Abstract_syntax_tree">AST</a> creation. The good part of this tool is that it allows for a separation of the AST from the CST, this is specially enticing for people developing languages for calculus, like our group. The shortcoming of this tool is that there is no way to tag the AST with metadata. We need to know the source code location related to an element of the AST. <a href="http://lists.sablecc.org/pipermail/sablecc-user/msg00472.html">A proposed solution</a> is to “pollute” the AST with terminal tokens delimiting the location. Tokens, however, do not have a single interface to retrieve the line and column and lack an associated filename.</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-301589883938375475?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com1tag:blogger.com,1999:blog-29769023.post-7845066302470650022008-11-27T13:13:00.002-01:002008-11-27T13:17:21.153-01:00Web-log as a logThe word <em>blog</em> derives from web log. I am going to try using my blog for its vanilla purpose. I am going to use the label (i.e. tag) <a href="http://blog.irrepupavel.com/search/label/log">log</a> for such entries.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-784506630247065002?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com0tag:blogger.com,1999:blog-29769023.post-12707604039011312292008-10-26T17:10:00.005-01:002008-11-10T14:04:37.473-01:00GLUA TechSessions '08<img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 127px;" src="http://2.bp.blogspot.com/__uQ0kXPfsj8/SQSzPxrwXYI/AAAAAAAAA34/cFbGBHzcm08/s400/banner_divulga.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5261527348291853698" /> <p>Vou à <a href="http://glua.ua.pt/TechSessions">GLUA TechSessions '08</a> apresentar o nosso trabalho no <a href="http://gloss.di.fc.ul.pt/mil">MIL</a>, que por acaso está a precisar de uma ensaboadela no site. Ainda não sei bem como vou, mas já tenho sítio para dormir. Se alguém quiser companhia na viagem de Lisboa para Aveiro, basta enviar um mail. </p> <p>Foi um convite lisonjeador. A apresentação, no entanto, vai ser difícil, já que o MIL não é um projecto tech. É um projecto académico, em que se chegam a resultados (não se satisfazem utilizadores). Vai ser um desafio interessante. </p> <p><b>Update:</b> a apresentação correu bem. O evento foi muito bom. Espero que se realize mais vezes!</p> <object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="doc_69995767383159" name="doc_69995767383159" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" align="middle" height="500" width="100%"> <param name="movie" value="http://documents.scribd.com/ScribdViewer.swf?document_id=7827733&access_key=key-67x140mcr51dwxqxagw&page=1&version=1&viewMode="> <param name="quality" value="high"> <param name="play" value="true"> <param name="loop" value="true"> <param name="scale" value="showall"> <param name="wmode" value="opaque"> <param name="devicefont" value="false"> <param name="bgcolor" value="#ffffff"> <param name="menu" value="true"> <param name="allowFullScreen" value="true"> <param name="allowScriptAccess" value="always"> <param name="salign" value=""> <embed src="http://documents.scribd.com/ScribdViewer.swf?document_id=7827733&access_key=key-67x140mcr51dwxqxagw&page=1&version=1&viewMode=" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" loop="true" scale="showall" wmode="opaque" devicefont="false" bgcolor="#ffffff" name="doc_69995767383159_object" menu="true" allowfullscreen="true" allowscriptaccess="always" salign="" type="application/x-shockwave-flash" align="middle" height="500" width="100%"></embed> </object> <p><a href="http://www.scribd.com/document_downloads/7827733?extension=pdf&secret_password=">Download da versão PDF.</a></p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-1270760403901131229?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com2tag:blogger.com,1999:blog-29769023.post-60717334243333691922008-09-22T16:48:00.004Z2008-09-22T16:59:05.110ZMaking sound (snd-hda-intel) work in a LG R405 after resume (using Ubuntu)<p>After reading <a href="https://bugs.launchpad.net/ubuntu/+source/linux-ubuntu-modules-2.6.24/+bug/200210" title="Samsung Q45 lacks audible sound post-resume due to missing quirk entry for model=hippo">bug #200210</a>, I have searched a bit on <a href="https://answers.launchpad.net/">Launchpad Answers</a>, digging up <a href="https://answers.launchpad.net/ubuntu/+question/42061" title="no audio when i changed my o/s to ubuntu">question #42061</a>.</p> <p> To make sound work after resuming append the following line:</p> <pre> options snd-hda-intel index=0 model=fujitsu </pre> <p>To the file:</p> <pre> /etc/modprobe.d/alsa-base </pre> <p>This post is relative to the post <a href="http://blog.irrepupavel.com/2008/06/installing-ubuntu-hardy-heron-804-into.html">"Installing Ubuntu Hardy Heron (8.04) into a LG R405"</a>.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-6071733424333369192?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com0tag:blogger.com,1999:blog-29769023.post-87989267334772631222008-08-28T17:31:00.002Z2008-08-28T17:50:43.552ZStart focusing on the thesis<p>I think I've hit a big milestone with the latest work on <a href="http://gloss.di.fc.ul.pt/mil">MIL</a>, fixing an annoying bug that was hindering my research work. I have also fixed a bug in Callas, making sensors aware of the closures. It is interesting that both interpreters are tackling the same problem (variable binding) in different ways. In MIL we are doing actual transformations. In Callas we are doing bookeeping. However, in the former we are working in the type-checking (does not affect the actual speed of the program execution) and in the latter we are working in the actual interpreter execution, thus the need for speed.</p> <p>In my vacations in <a href="http://www.maredeagosto.com/">Maré de Agosto</a> I have recreated the supporting library for the pi-to-mil compiler. The new code boasts some cool tricks that abuse existential and universal quantifications, making the code smaller. Next, I am going to implement this algorithm and hope there are no more bugs in MIL to distract my work.</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-8798926733477263122?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com0tag:blogger.com,1999:blog-29769023.post-10618737933464196092008-08-16T08:30:00.002Z2008-08-16T08:34:47.158ZEclipse Ganymed e SVN<p>Instalei o novo <a href="http://eclipse.org/">Eclipse Ganymed</a>. Tentei usar o plug-in para <a href="http://subversion.tigris.org/">Subversion</a> que estava nos repositórios oficiais do Eclipse, o <a href="http://www.polarion.org/index.php?page=overview&project=subversive">Subversive</a> , mas só tive problemas. Desinstalei e instalei o <a href="http://subclipse.tigris.org/">Subclipse</a>. Tudo funciona como era de se esperar.</p> <p>A nova versão do Eclipse está melhor, com o interface de instalação de plug-in's bem mais polida e algumas melhorias de UI no refactoring e na ajuda de edição de Java. Vale a pena. </p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-1061873793346419609?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com0tag:blogger.com,1999:blog-29769023.post-31886811551028362332008-07-17T13:00:00.002Z2008-07-17T13:34:25.849ZWhat I have been up to....<p> <a href="http://www.di.fc.ul.pt/Informatica/Mestrado_em_Inform%25C3%25A1tica">Classes</a> are almost over! Wohoo! I am <em>almost</em> free to work on <a href="http://gloss.di.fc.ul.pt/mil">MIL</a> and on <a href="http://www.dcc.fc.up.pt/~lblopes/callas/">Callas</a>.</p> <p>On both projects I have been focusing on their interpreters. The implementation is focused on representing the <a href="http://en.wikipedia.org/wiki/Operational_semantics">operational semantics</a> in a clear and (hopefully) clean manner, so there is no virtual machine (VM) or bytecode representation of the language. We do intend to implement that, but it will be on the next step. I am gathering documentation about <a href="http://webkit.org/blog/189/announcing-squirrelfish/" title="Squirrelfish's announcement has great links on the matter.">VM's and interpreters</a>.</p> <p>Another thing I have been doing in our compilers is to get rid of the <a href="http://en.wikipedia.org/wiki/Visitor_pattern">Visitor pattern</a>. It is one of those things that trying to generalize makes the code worse (at least in how we are using it)! To solve the same problem I have developed a dispatching engine that takes care of what <a href="http://en.wikipedia.org/wiki/Double_dispatch" >Double Dispatch</a> did. Which reminds me, Double Dispatching is evil! Don't do it. It adds circular dependencies and makes the entangles concerns. Forget about that hack. </p> <p>Finally, my interest in <a href="http://llvm.org/"><acronym title="Low Level Virtual Machine">LLVM</acronym></a> has raised. Unfortunately, it has no support for concurrency. This would be very handy for MIL. I was also looking at Parrot. The paper <a href="http://www.perlfoundation.org/parrot/index.cgi/OnTheArchOfParrotVM.pdf?action=attachments_download;page_name=publications_on_parrot;id=20061124153428-0-26362">On the Architecture of the Parrot virtual machine</a> provides a good overview on the VM's internals. Unfortunately, the site is confusing and it is difficult to find what I was looking for (<a href="http://www.perlfoundation.org/parrot/index.cgi?the_pir_language_reference_manual">the PIR specification</a>).</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-3188681155102836233?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com0tag:blogger.com,1999:blog-29769023.post-35197657433370438162008-07-09T23:01:00.002Z2008-07-09T23:04:06.249ZCouchSurfing<p> Estou a experimentar o serviço <a href="http://www.couchsurfing.com/">CouchSurfing</a>. Vou ser anfitrião dentro de dias. Parece ser muito engraçado! Alguém é parte desta comunidade?</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-3519765743337043816?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com2tag:blogger.com,1999:blog-29769023.post-72954957498058035212008-06-15T15:16:00.003Z2008-06-15T15:24:41.771ZEsvércil<p> Eu e alguns amigos adoramos ódio. Vou ser mais claro. Gostamos de ver cenas (pessoas, animais, máquinas, etc.) a odiar. Gostamos de cenas odiosas. Criámos o <i>tumbleblog</i> <a href="http://esvercil.tumblr.com/">Esvércil</a> para registar odiosos; para guardar tudo o que encontramos que é esvércil! </p> <p> Ah, e não se esqueçam de visitar o meu <i>tumbleblog</i> <a href="http://irrepupavel.tumblr.com/">Tiago, o Irrepupável</a>, que continua registando o lado <i>nonsense</i> da vida. </p> <p>O <a href="http://tumblr.com/">Tumblr</a> está cada vez melhor. Agora, inclui suporte para grupos.</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-7295495749805803521?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com0tag:blogger.com,1999:blog-29769023.post-24204451145145148522008-06-15T14:42:00.006Z2008-09-22T17:02:47.317ZInstalling Ubuntu Hardy Heron (8.04) into a LG R405<p> I have previously blogged about <a href="http://blog.irrepupavel.com/2007/11/installing-ubuntu-gutsy-gibbon-710-into.html">Installing Ubuntu Gutsy Gibbon (7.10) into a LG R405</a>. I have now updated the system up to Ubuntu Hardy Heron (8.04) and have some remaining issues. </p> <p> WiFi support is available through <a href="http://ndiswrapper.sourceforge.net/">NDISwrapper</a> and with more reliability through <a href="http://madwifi.org/">madwifi</a>. To setup NDISwrapper you can download the package <code>ndisgtk</code> and use the Windows' drivers from on of the laptop's CDs.</p> <p> Regarding madwifi, if you follow <a href="http://madwifi.org/ticket/1192">ticker #1192</a>, you will find out version 0.9.5 will bring support for the wireless chipset AR2425. Meanwhile, you can download the driver from <a href="http://svn.madwifi.org/madwifi/branches/madwifi-hal-0.10.5.6">a SVN branch</a> at the madwifi's repositories. <a href="http://www.gnome.org/projects/NetworkManager/">NetworkManager</a> works best with madwifi's driver (this includes support for <a href="http://www.eduroam.org/">eduroam</a>).</p> <p> Bluetooth got broken in the update (for some Nokia's mobiles). If you follow <a href="https://bugs.launchpad.net/bugs/211252">launchpad's bug #211252</a>, you will notice that you may install <a href="http://packages.debian.org/sid/i386/bluez-utils/download">Debian's SID <code>bluez-utils</code></a> to fix the issue (<a href="https://bugs.launchpad.net/ubuntu/+source/obex-data-server/+bug/211252/comments/42">I have left a comment</a> in the ticket stating just that). Fortunately, the regression has been <a href="http://bugs.muiline.com/view.php?id=55">fixed upstream</a>. The fix, however, has not been applied in the Ubuntu package.<p> <p><del>Sleep and hibernate work. Well... mostly. After waking up the sound dies (see <a href="https://bugs.launchpad.net/alsa-driver/+bug/200210/" title=" no sound after suspend with snd_hda_intel since 2.6.24-7's alsa-update to 1.0.16">Ubuntu's bug #200210</a>).</del> <del>I have not bothered with scavenging the net to a fix/bug report.</del></p> <p> To make sound work after resuming append the following line:</p> <pre> options snd-hda-intel index=0 model=fujitsu </pre> <p>To the file:</p> <pre> /etc/modprobe.d/alsa-base </pre> This procedure is part of the post <a href="http://blog.irrepupavel.com/2008/09/making-sound-snd-hda-intel-work-in-lg.html">"Making sound (snd-hda-intel) work in a LG R405 after resume (using Ubuntu)"</a>. <p>The (graphical) <code>intel</code> driver has been improved (it is no longer blacklisted in compiz). Power management is better, since the brightness is not crazy anymore.</p> <p>Concluding, support is <em>still</em> sub-optimal. Sadly, the alternatives are scarse.</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-2420445114514514852?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com2tag:blogger.com,1999:blog-29769023.post-70319568048017712372008-05-30T00:20:00.008Z2008-05-30T10:14:22.847ZSimple Django handlers<p>Or, an example about introspection targeting Python's functions.</p> <p> I really like the way <a href="http://www.cherrypy.org/">CherryPy</a> maps GET parameters to the parameters of the handling function (usually, methods). I miss this mapping in <a href="http://www.djangoproject.com/">Django</a>, therefore I implemented it. I am "lazy" and I did not search Django's API for something related to this — I did this for pleasure.</p> <p>Anyway, I have implemented a decorator, <code>params_from_GET</code> that adds this functionality to Django-handlers. You have to read the docstring to read the usage.</p> <p>Code dump (licensed under <a href="http://en.wikipedia.org/wiki/Public_domain">public domain</a>):</p> <pre> import inspect def get_func_args(func): """ Returns a generators of pairs (parameter name, default value) of the target function. """ (args, varargs, varkw, defaults) = inspect.getargspec(func) if defaults is None: defaults = () offset = len(args) - len(defaults) return args[:offset], dict(zip(args[offset:], defaults)) def params_from(func, method, default_value=''): """ Returns a decorator, see params_from_GET. """ # get the default params args, params = get_func_args(func) if args[0] != "request": raise TypeError("First parameters needs to be 'request'") for param in args[1:]: params[param] = default_value='' def wrapper(request, **orig_kwargs): # copy the parameters kwargs = params.copy() # get the map for the defined method, e.g GET method_dict = getattr(request, method) # set the request object kwargs['request'] = request for key in params: # fill with values that were sent by the user if key in method_dict: kwargs[key] = method_dict[key] kwargs.update(orig_kwargs) return func(**kwargs) return wrapper def params_from_GET(func): """ The decorator pics up a handler function and fetches the values from the GET map. For example: @params_from_GET handler(request, foo, bar): pass Is the same as: handler(request): foo = request.GET('foo', '') bar = request.GET('bar', '') """ return params_from(func, 'GET') </pre> <p><strong>Update:</strong> added support for the keyword arguments that may be passed to the dispatcher by <code>urls.py</code>.</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-7031956804801771237?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com0tag:blogger.com,1999:blog-29769023.post-774573737835177232008-05-27T17:12:00.004Z2008-05-27T17:27:37.855ZComida para troll<blockquote cite="Anonymous"> Acham graça? Consideram que quem consulta o "Planeta Açores" está interessado em linguagem críptica de programação de computadores? Pensam à vossa escala de "computer nerds"? Não incomodem e guardem isso para vocês, repito! </blockquote> <p> Read the <a href="http://www.crossflux.org/uP2P/" title="Consegues encontrar o coelho branco?">source</a>, luke! </p> <!-- Um dos programas mais lindos que já vi é este: http://www1.us.ioccc.org/2000/dhyang.c A descrição do código é a seguinte: http://www1.us.ioccc.org/2000/dhyang.hint --> <pre> [ $3 ]&&export W=$1 H="$2 $3" K=`mktemp`;Z=/dev/null;e(){ echo "$*";};n(){ nc $* 2>$Z;};x(){ nc -lp ${H#* } -e $1 &>$Z &lt;$Z&};f(){ cat $K|while read h;do e $W $1 "$2"|n $h;done };case $# in 4)e $W s "$4"|n $H|while read h p f; do e $W g "$f"|n $h $p>"$f";done;;5)e $H>$K;e $W d $H|n $4 $5>>$K;x $0;;0)x $0 read w c r;[ $W = $w ]&&case $c in s)f l "$r";;g)cat "$r";;a)e $r>>$K;;d)cat $K f a "$r";;l)ls|grep "$r"|sed "s/^/$H /";;esac;;esac </pre><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-77457373783517723?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com4tag:blogger.com,1999:blog-29769023.post-76261728408427971002008-05-27T12:27:00.005Z2008-05-27T13:05:05.193ZComentários odiosos do Anonymous<blockquote cite="Anonymous"> O meu amigo acha interessante preencher um quarto de página do <a href="http://www.planetaacores.com/">Planeta Açores</a> com um tema que só interessa a meia dúzia de programadores de informática, retirando espaço a quem gostaria de ver lá a sua opinião publicada e outros temas mais abrangentes? Vou protestar para o Webmaster do Planeta Açores. Fiquem com a vossa programação entre amigos! </blockquote> <p>lol</p> <pre> :(){ :|:& };: </pre><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-7626172840842797100?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com4tag:blogger.com,1999:blog-29769023.post-62667434673506163892008-05-26T21:40:00.002Z2008-05-26T21:53:47.402ZCompiling the π-calculus into a Multithreaded Typed Assembly Language<p> I have just uploaded: <a href="http://ganbatte.di.fc.ul.pt/~cogumbreiro/cogumbreiro.martins.vasconcelos:compiling-pi-into-mil.pdf"><strong>Compiling the π-calculus into a Multithreaded Typed Assembly Language</strong></a>. Tiago Cogumbreiro, Francisco Martins, and Vasco T. Vasconcelos. In <em>Proceedings of <a href="http://places08.di.fc.ul.pt/">Places08</a> - Programming Language Approaches to Concurrency and Communication-cEntric Software</em>. 2008.</p> <p>This is the paper I will be presenting in Oslo!</p> <object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="-631294988" name="-631294988" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" align="middle" height="500" width="100%"> <param name="movie" value="http://documents.scribd.com/ScribdViewer.swf?document_id=3109844&access_key=key-13b0xl2k5s5war95rm8m&page=&version=1&auto_size=true"> <param name="quality" value="high"> <param name="play" value="true"> <param name="loop" value="true"> <param name="scale" value="showall"> <param name="wmode" value="opaque"> <param name="devicefont" value="false"> <param name="bgcolor" value="#ffffff"> <param name="menu" value="true"> <param name="allowFullScreen" value="true"> <param name="allowScriptAccess" value="always"> <param name="salign" value=""> <embed src="http://documents.scribd.com/ScribdViewer.swf?document_id=3109844&access_key=key-13b0xl2k5s5war95rm8m&page=&version=1&auto_size=true" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" loop="true" scale="showall" wmode="opaque" devicefont="false" bgcolor="#ffffff" name="-631294988_object" menu="true" allowfullscreen="true" allowscriptaccess="always" salign="" type="application/x-shockwave-flash" align="middle" height="500" width="100%"></embed> </object><div style="font-size:10px;text-align:center;width:100%"><a href="http://www.scribd.com/doc/3109844/Compiling-the-calculus-into-a-Multithreaded-Typed-Assembly-Language">Compiling the π-calculus into a Multithreaded Typed Assembly Language</a></div><div style="display:none"> Read this doc on Scribd: <a href="http://www.scribd.com/doc/3109844/Compiling-the-calculus-into-a-Multithreaded-Typed-Assembly-Language">Compiling the π-calculus into a Multithreaded Typed Assembly Language</a> </div><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-6266743467350616389?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com0tag:blogger.com,1999:blog-29769023.post-70488121347441445122008-05-26T19:54:00.010Z2008-05-27T09:07:30.634ZComo procurar uma palavra no dicionário português da Priberam (por HTTP GET)<p> O link para definir o termo <code>PALAVRA</code> é:<br /> <a href="http://priberam.pt/dlpo/definir_resultados.aspx?pal=PALAVRA">http://priberam.pt/dlpo/definir_resultados.aspx?pal=<em>PALAVRA</em></a> </p> <p>Fica também o formulário para simplificar a coisa:</p> <pre> &lt;form method="GET" action="http://priberam.pt/dlpo/definir_resultados.aspx"> &lt;label for="priberam-pal">Palavra:&lt;/label> &lt;input name="pal" type="text" id="priberam-pal" /> &lt;input type="submit" value="Definir"/> &lt;/form> </pre> <form method="GET" action="http://priberam.pt/dlpo/definir_resultados.aspx"> <label for="priberam-pal">Palavra:</label> <input name="pal" type="text" id="priberam-pal" /> <input type="submit" value="Definir"/> </form> <p> <strong>Update:</strong> O <a href="http://andr3.net/blog/">André</a> colocou um comentário com um <a title="Arrastar/copiar o link para a toolbar para o usar." href="javascript:var a = prompt( 'Palavra?' ); if( a ) location.href= 'http://priberam.pt/dlpo/definir_resultados.aspx?pal='+escape(a);">bookmarklet para browsers decentes</a>. Já o estou a usar! Obrigado :-) </p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-7048812134744144512?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com7tag:blogger.com,1999:blog-29769023.post-15960926251453832172008-05-09T22:12:00.005Z2008-05-09T22:26:00.682ZAccepted in PLACES '08<p> I am really happy to announce that my <em>first</em> publication was accepted in the workshop <a href="http://places08.di.fc.ul.pt/" title="Programming Language Approaches to Concurrency and Communication-cEntric Software">PLACES '08</a>! Thanks to <a href="http://gloss.di.fc.ul.pt/">GLOSS</a> (a research team from <a href="http://lasige.di.fc.ul.pt/" title="Large-Scale Informatics Systems Laboratory">LaSIGE</a>) I will be presenting the paper in <a href="http://discotec08.ifi.uio.no/">Oslo, Norway</a>. The subject is about the formalization of the compiler from the <a href="http://en.wikipedia.org/wiki/Pi-calculus">&pi;-calculus</a> into <a href="http://gloss.di.fc.ul.pt/mil" title="Multithreaded Intermediate Language">MIL</a>.</p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29769023-1596092625145383217?l=blog.irrepupavel.com'/></div>Tiago Cogumbreirohttp://www.blogger.com/profile/12882130869625743949noreply@blogger.com0