David Vázquez2021-07-12T21:38:22+00:00/http://davazp.net/2014/11/26/modern-library-with-asdf-and-package-inferred-systemHow to write a modern Lisp library with ASDF3 and Package Inferred System2014-11-26T00:00:00+00:002014-11-26T00:00:00+00:00David Vázquez/2014/11/26/modern-library-with-asdf-and-package-inferred-system<p>If you are a novice Lisp programmer and you are confused about the
difference between <em>systems</em> and <em>packages</em>, I recommend you to read
the <a href="http://weitz.de/packages.html" title="Packages, systems, modules, libraries - WTF?">Packages, systems, modules, libraries - WTF?</a> before you
continue.</p>
<h3 id="introduction">Introduction</h3>
<p>The most common way that people use packages nowadays is by adding a
<code class="language-plaintext highlighter-rouge">packages.lisp</code> or <code class="language-plaintext highlighter-rouge">package.lisp</code> file. This file is usually the first
file to be loaded and define the packages that the other files
use. This approach has worked for many projects. However, when
packages become larger, it requires discipline to manage the
dependencies between the files.</p>
<p>An alternative approach to the definition of packages is named <em>one
package per file</em>. As the name suggests, it consists in starting every
file with a <a href="http://clhs.lisp.se/Body/m_defpkg.htm">defpackage</a>. Because
dependencies between packages are explicit and every file has a unique
package, the dependencies between the files can be inferred.</p>
<p>This style of programming was introduced a few years ago by <em>faslpath</em>
and <em>quick-build</em>. But recently, the <em>de facto</em> standard Common Lisp
build system <a href="http://common-lisp.net/project/asdf/">ASDF3</a> added
support for it with the <em>asdf-package-system</em> extension. As a
consequence, now it is easier than ever to use it.</p>
<p>So, stay with me for the next minutes and you will learn how to use
this new approach in your projects. I hope you find it useful.</p>
<h3 id="how-to-use-it">How to use it</h3>
<p>First of all, we have to enable the <em>asdf-package-system</em> extension on
our system. We will work on a system named <code class="language-plaintext highlighter-rouge">project</code> as definition
follows</p>
<figure class="highlight"><pre><code class="language-common-lisp" data-lang="common-lisp"><span class="p">(</span><span class="nv">asdf:defsystem</span> <span class="ss">:project</span>
<span class="ss">:name</span> <span class="s">"My Project"</span>
<span class="ss">:version</span> <span class="s">"0.0.1"</span>
<span class="ss">:class</span> <span class="ss">:package-inferred-system</span>
<span class="ss">:defsystem-depends-on</span> <span class="p">(</span><span class="ss">:asdf-package-system</span><span class="p">)</span>
<span class="ss">:depends-on</span> <span class="p">(</span><span class="ss">:project/addons</span><span class="p">))</span></code></pre></figure>
<p>This defines a correspondence between systems, packages and files. A
system <code class="language-plaintext highlighter-rouge">project/foo/bar</code> refers the file <code class="language-plaintext highlighter-rouge">foo/bar.lisp</code>, which have to
provide a package <code class="language-plaintext highlighter-rouge">project/foo/bar</code>, and whose <em>used</em> and <em>imported</em>
packages refer to systems of the same name.</p>
<p>For example, as the system <code class="language-plaintext highlighter-rouge">project</code> depends on <code class="language-plaintext highlighter-rouge">project/addons</code>, the
file <code class="language-plaintext highlighter-rouge">addons.lisp</code> must be loaded first. The content of <code class="language-plaintext highlighter-rouge">addons.lisp</code>
starts with:</p>
<figure class="highlight"><pre><code class="language-common-lisp" data-lang="common-lisp"><span class="p">(</span><span class="nb">defpackage</span> <span class="ss">:project/addons</span>
<span class="p">(</span><span class="ss">:use</span> <span class="ss">:common-lisp</span> <span class="ss">:project/core</span><span class="p">)</span>
<span class="p">(</span><span class="ss">:import-from</span> <span class="ss">:cl-ppcre</span><span class="p">))</span>
<span class="p">(</span><span class="nb">in-package</span> <span class="ss">:project/addons</span><span class="p">)</span>
<span class="p">(</span><span class="nv">cl-ppcre:scan-to-strings</span> <span class="s">"h.*o"</span> <span class="p">(</span><span class="nv">hello</span><span class="p">))</span></code></pre></figure>
<p>Note that it uses the package <code class="language-plaintext highlighter-rouge">project/core</code> and “import” the
<code class="language-plaintext highlighter-rouge">cl-ppcre</code> one. Therefore, ASDF will infer that it depends on both the
<em>systems</em> <a href="http://weitz.de/cl-ppcre/">cl-ppcre</a> and <code class="language-plaintext highlighter-rouge">project/core</code>, so
they must be loaded first. But remember, the system <code class="language-plaintext highlighter-rouge">project/core</code>
refers to the file <code class="language-plaintext highlighter-rouge">core.lisp</code>:</p>
<figure class="highlight"><pre><code class="language-common-lisp" data-lang="common-lisp"><span class="p">(</span><span class="nb">defpackage</span> <span class="ss">:project/core</span>
<span class="p">(</span><span class="ss">:use</span> <span class="ss">:common-lisp</span><span class="p">)</span>
<span class="p">(</span><span class="ss">:export</span> <span class="ss">#:hello</span><span class="p">))</span>
<span class="p">(</span><span class="nb">in-package</span> <span class="ss">:project/core</span><span class="p">)</span>
<span class="p">(</span><span class="nb">defun</span> <span class="nv">hello</span> <span class="p">()</span>
<span class="s">"Hello!"</span><span class="p">)</span></code></pre></figure>
<p>And that is all. This file has no external dependencies. Then, if we
try to load our system</p>
<div class="language-common-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nv">asdf:load-system</span> <span class="s">"project"</span><span class="p">)</span>
</code></pre></div></div>
<p>the systems and files <code class="language-plaintext highlighter-rouge">core.lisp</code>, <code class="language-plaintext highlighter-rouge">cl-ppcre</code> and <code class="language-plaintext highlighter-rouge">addons.lisp</code> will
be loaded in the proper order.</p>
<h3 id="integration-with-other-systems">Integration with other systems</h3>
<p>What if we use a package but the system that provides such a package
has not the same (downcased) name? For example, the system
<a href="http://common-lisp.net/project/closer/closer-mop.html">closer-mop</a>
provides a package named <em>c2cl</em>. In order to let ASDF know how to find
the system for a package, we can call the function
<code class="language-plaintext highlighter-rouge">register-system-packages</code> with the name of the systems and the
packages it provides as argument. In our case, we would include the
following in our <code class="language-plaintext highlighter-rouge">project.asd</code>:</p>
<div class="language-common-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nv">register-system-packages</span> <span class="ss">:closer-mop</span> <span class="o">'</span><span class="p">(</span><span class="ss">:c2cl</span><span class="p">))</span>
</code></pre></div></div>
<h3 id="a-last-trick">A Last Trick</h3>
<p>Most of the time we want to <em>export</em> a single package with all the
symbols from the “subpackages”. This can be done very easily if you
use the <em>UIOP</em> library shipped with ASDF. For example, let us define a
file named <code class="language-plaintext highlighter-rouge">all.lisp</code> in our example like:</p>
<figure class="highlight"><pre><code class="language-common-lisp" data-lang="common-lisp"><span class="p">(</span><span class="nv">uiop/package:define-package</span> <span class="ss">:project/all</span>
<span class="p">(</span><span class="ss">:nickname</span> <span class="ss">:project</span><span class="p">)</span>
<span class="p">(</span><span class="ss">:use-reexport</span> <span class="ss">:project/core</span> <span class="ss">:project/addons</span><span class="p">))</span></code></pre></figure>
<p>Now, the system <code class="language-plaintext highlighter-rouge">project/all</code> depends on both <code class="language-plaintext highlighter-rouge">project/core</code> and
<code class="language-plaintext highlighter-rouge">project/addons</code>, and it will reexport the symbols into a <code class="language-plaintext highlighter-rouge">:project</code>
package.</p>
<h3 id="futher-information">Futher information</h3>
<p>If you want to know more about ASDF3 and package-system:</p>
<ul>
<li>
<p><a href="http://common-lisp.net/project/asdf/asdf/The-package_002dinferred_002dsystem-extension.html#The-package_002dinferred_002dsystem-extension">ASDF Manual. The package-inferred-system extension</a>.</p>
</li>
<li>
<p>ASDF 3, or Why Lisp is Now an Acceptable Scripting Language<br />
(Extended version) by François-René Rideau.<br />
<a href="http://fare.tunes.org/files/asdf3/asdf3-2014.html">http://fare.tunes.org/files/asdf3/asdf3-2014.html</a></p>
</li>
</ul>
http://davazp.net/2013/07/16/Low-level-PostgreSQL-access-from-LispPostgreSQL from Lisp2013-07-16T00:00:00+00:002013-07-16T00:00:00+00:00David Vázquez/2013/07/16/Low-level-PostgreSQL-access-from-Lisp<p>Hello everybody,</p>
<p>It has been a long time before my last post. Many things happened: I
had a great time in <a href="http://weitz.de/eclm2013/">ECL2013</a>, I
<a href="https://github.com/davazp/jscl/blob/master/src/compiler/codegen.lisp">wrote a code generator for JSCL</a>,
exams in the university… and suffering the heat at home in Spain, of
course.</p>
<p>These days, at work, I am migrating our old SQL Server to PostgreSQL.
We used to use CLSQL to access to the server from Lisp-side, but in a
very straightforward way. We built everything on <code class="language-plaintext highlighter-rouge">query</code>. Although
CLSQL is a big monster, it misses parametric queries, and you have to
escape arguments yourself. Indeed, it was not as much stable as I
would like. But let apart exotic features.</p>
<p>Therefore I gave a try to other libraries. The obvious choice would be
<a href="http://marijnhaverbeke.nl/postmodern/">Postmodern</a>, but it failed
soon. DAO capabilities seem incomplete and, I think, they should be
other library, but I can live ignoring it. However, have a look to
<a href="http://marijnhaverbeke.nl/postmodern/postmodern.html#query">query</a>:
it has a strange arg/format mix and it is a macro! It means you will
fail to build simple abstractions on it.</p>
<p>Fortunately, Postmodern’s author created a lower library
<a href="http://marijnhaverbeke.nl/postmodern/cl-postgres.html">cl-postgres</a>,
which I can suit easily:</p>
<div class="language-common-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nb">defun</span> <span class="nv">query</span> <span class="p">(</span><span class="nv">query</span> <span class="k">&rest</span> <span class="nv">args</span><span class="p">)</span>
<span class="p">(</span><span class="nv">cl-postgres:prepare-query</span> <span class="vg">*database*</span> <span class="s">""</span> <span class="nv">query</span><span class="p">)</span>
<span class="p">(</span><span class="nv">cl-postgres:exec-prepared</span> <span class="vg">*database*</span> <span class="s">""</span> <span class="nv">args</span> <span class="ss">'cl-postgres:list-row-reader</span><span class="p">))</span>
</code></pre></div></div>
<p>but of course I will have to write connection pooling and other
features myself, or perhaps mix postmodern and cl-postgres carefully.</p>
<p>In conclusion, I think we should be a little bit more <em>conventional</em>
in the abstractions we build, and not to forget intermediate
abstractions.</p>
http://davazp.net/2013/05/01/the-surprising-jscl-risingThe surprising JSCL rising2013-05-01T00:00:00+00:002013-05-01T00:00:00+00:00David Vázquez/2013/05/01/the-surprising-jscl-rising<p>I am just back from a few days of holidays and have seen how active
JSCL is! It is really exciting.</p>
<p>This rising is due to <a href="https://github.com/abeaumont">abeaumont</a>
probably. I stopped working, but he came up with an idea I liked. It
is, why don’t integrate JSCL into <a href="http://conkeror.org/">Conkeror</a>?
We would end up with a Lisp programmable browser… that’s a practical
reason! We did some tests locally and it seemed to work, but now it
is time for improving JSCL itself.</p>
<p>It is not the only platform where JSCL could run on. I plan to add
support for <a href="http://nodejs.org/">Node JS</a>. Indeed, it will let us use
the REPL and tests in the terminal in addition to the browser, which
is a much more convenient way to program.</p>
<p>In the meantime, I would like to improve the compiler a little bit.</p>
<p>Suggestion and patches are very welcome if you want to join us.</p>
<p><a href="https://github.com/davazp/jscl">https://github.com/davazp/jscl</a></p>
http://davazp.net/2013/04/11/back-in-actionBack in action2013-04-11T00:00:00+00:002013-04-11T00:00:00+00:00David Vázquez/2013/04/11/back-in-action<p>Hello everyone. I have been away some days from the computer, but I am
back now! I have spent two weeks in New York visiting such a great
city. I had the opportunity to attend to a LispNYC meetup and enjoy
the great atmosphere there. I hope to come back soon.</p>
<p>I have also a new laptop. Finally, I have to say, as I inherited the
last one from my brother and I have been using it for 6 years. Most of
the time it was good enough but it is becoming very annoying. For
example, I could not compile SBCL because it was restarted due to
overheating..</p>
<p>I feel like doing things now so I wish I could tell you new adventures
soon.</p>
http://davazp.net/2013/03/06/Forth-model-illustrationForth model illustration2013-03-06T00:00:00+00:002013-03-06T00:00:00+00:00David Vázquez/2013/03/06/Forth-model-illustration<p>I like old systems which expose a good part of their internals,
specially when they are so simple. I created this animation using
<a href="http://ditaa.sourceforge.net/">ditaa</a> to illustrate how execution is
done in Forth:</p>
<p><img src="/img/eulex/forth.gif" alt="forth-model-ilustration" /></p>
<p>Of course, it only makes sense if you already know Forth. But I guess
you do not know many languages where such thing is possible.</p>
http://davazp.net/2013/01/24/Special-argumentsSpecial arguments2013-01-24T00:00:00+00:002013-01-24T00:00:00+00:00David Vázquez/2013/01/24/Special-arguments<p>I have learnt a new trick these days. Did you know that you can
declare an argument as a special variable? Quoting <a href="http://www.lispworks.com/documentation/HyperSpec/Body/03_daa.htm">Hyperspec</a>:</p>
<blockquote>
<p>Each required parameter is specified by a parameter variable var. var
is bound as a lexical variable <em>unless it is declared special</em>.</p>
</blockquote>
<p>It seems to work also for optional and keyword arguments, but
Hyperspec does not mention it explicitly. For example, yo can do:</p>
<div class="language-common-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nb">defvar</span> <span class="vg">*variable*</span><span class="p">)</span>
<span class="p">(</span><span class="nb">defun</span> <span class="nv">foo</span> <span class="p">()</span> <span class="vg">*variable*</span><span class="p">)</span>
<span class="p">(</span><span class="nb">defun</span> <span class="nv">foobar</span> <span class="p">(</span><span class="k">&optional</span> <span class="vg">*variable*</span><span class="p">)</span>
<span class="p">(</span><span class="nv">foo</span><span class="p">))</span>
</code></pre></div></div>
http://davazp.net/2013/01/04/lisp-to-javascriptLisp to Javascript compiler2013-01-04T00:00:00+00:002013-01-04T00:00:00+00:00David Vázquez/2013/01/04/lisp-to-javascript<hr />
<p><strong>UPDATE 22 Nov 2014: The project was renamed to <em>JSCL</em> and now is hosted at <a href="http://github.com/davazp/jscl">http://github.com/davazp/jscl</a>.
You can also try <a href="http://davazp.net/jscl/jscl.html">the live demo</a>.</strong></p>
<hr />
<p><a href="http://puntoblogspot.blogspot.ie/">Raimon Grau</a> and I have been
working on a simple Lisp to Javascript compiler, in order to better
understand how to bootstrap it. Now we got it. It compiles itself and
the resulting code can be used from the browser. It can even call its
own internals, which is quite nice.</p>
<p>It is not very helpful, you can
<a href="http://davazp.github.com/ecmalisp/ecmalisp.html">try it</a>. Now I have
to think if it could be useful for something… maybe a live Lisp
tutorial, or make it suitable for Android. Any suggestions?</p>
<p>The repository with the whole history is at:</p>
<p><a href="http://github.com/davazp/ecmalisp/">http://github.com/davazp/ecmalisp/</a></p>
<p><a href="http://puntoblogspot.blogspot.ie/">Raimon Grau</a> and I have been
working on a simple Lisp to Javascript compiler, in order to better
understand how to bootstrap it. Now we got it. It compiles itself and
the resulting code can be used from the browser. It can even call its
own internals, which is quite nice.</p>
<p>It is not very helpful, you can
<a href="http://davazp.github.com/ecmalisp/ecmalisp.html">try it</a>. Now I have
to think if it could be useful for something… maybe a live Lisp
tutorial, or make it suitable for Android. Any suggestions?</p>
<p>The repository with the whole history is at:</p>
<p><a href="http://github.com/davazp/ecmalisp/">http://github.com/davazp/ecmalisp/</a></p>
http://davazp.net/2012/12/13/Emphasizing-text-in-ERCEmphasizing text in ERC2012-12-13T00:00:00+00:002012-12-13T00:00:00+00:00David Vázquez/2012/12/13/Emphasizing-text-in-ERC<p>I have realized
<a href="http://www.gnu.org/software/emacs/manual/html_mono/erc.html">ERC</a>
supports control characters to emphasize text as bold, underline…
However, I prefer <code class="language-plaintext highlighter-rouge">*foo*</code>, <code class="language-plaintext highlighter-rouge">/bar/</code> and <code class="language-plaintext highlighter-rouge">_foobar_</code> syntax, just like
org-mode and Gnus. So I have added the following code to my .emacs to
do the job:</p>
<div class="language-emacs-lisp highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">(</span><span class="nb">defun</span> <span class="nv">erc-emphasize</span> <span class="p">()</span>
<span class="p">(</span><span class="nb">when</span> <span class="p">(</span><span class="nb">eq</span> <span class="nv">erc-interpret-controls-p</span> <span class="no">t</span><span class="p">)</span>
<span class="p">(</span><span class="nv">goto-char</span> <span class="p">(</span><span class="nv">point-min</span><span class="p">))</span>
<span class="p">(</span><span class="nv">while</span> <span class="p">(</span><span class="nv">re-search-forward</span> <span class="s">"\\(?:^\\|\\s-\\)\\(\\*\\([^*]+\\)\\*\\)\\(:?$\\|\\s-\\)"</span> <span class="no">nil</span> <span class="no">t</span><span class="p">)</span>
<span class="p">(</span><span class="nv">replace-match</span> <span class="s">"\C-b\\2\C-o"</span> <span class="no">nil</span> <span class="no">nil</span> <span class="no">nil</span> <span class="mi">1</span><span class="p">))</span>
<span class="p">(</span><span class="nv">goto-char</span> <span class="p">(</span><span class="nv">point-min</span><span class="p">))</span>
<span class="p">(</span><span class="nv">while</span> <span class="p">(</span><span class="nv">re-search-forward</span> <span class="s">"\\(?:^\\|\\s-\\)\\(_\\([^_]+\\)_\\)\\(?:$\\|\\s-\\)"</span> <span class="no">nil</span> <span class="no">t</span><span class="p">)</span>
<span class="p">(</span><span class="nv">replace-match</span> <span class="s">"\C-_\\2\C-O"</span> <span class="no">nil</span> <span class="no">nil</span> <span class="no">nil</span> <span class="mi">1</span><span class="p">))</span>
<span class="p">(</span><span class="nv">goto-char</span> <span class="p">(</span><span class="nv">point-min</span><span class="p">))</span>
<span class="p">(</span><span class="nv">while</span> <span class="p">(</span><span class="nv">re-search-forward</span> <span class="s">"\\(?:^\\|\\s-\\)\\(/\\([^/]+\\)/\\)\\(?:$\\|\\s-\\)"</span> <span class="no">nil</span> <span class="no">t</span><span class="p">)</span>
<span class="p">(</span><span class="nv">replace-match</span> <span class="s">"\C-V\\2\C-O"</span> <span class="no">nil</span> <span class="no">nil</span> <span class="no">nil</span> <span class="mi">1</span><span class="p">))))</span>
<span class="p">(</span><span class="nv">add-hook</span> <span class="ss">'erc-send-pre-hook</span>
<span class="p">(</span><span class="k">lambda</span> <span class="p">(</span><span class="nb">string</span><span class="p">)</span>
<span class="p">(</span><span class="nv">with-temp-buffer</span>
<span class="p">(</span><span class="nv">insert</span> <span class="nb">string</span><span class="p">)</span>
<span class="p">(</span><span class="nv">erc-emphasize</span><span class="p">)</span>
<span class="p">(</span><span class="k">setq</span> <span class="nv">str</span> <span class="p">(</span><span class="nv">buffer-substring</span> <span class="p">(</span><span class="nv">point-min</span><span class="p">)</span> <span class="p">(</span><span class="nv">point-max</span><span class="p">))))))</span>
<span class="p">(</span><span class="nv">add-hook</span> <span class="ss">'erc-insert-modify-hook</span> <span class="ss">'erc-emphasize</span><span class="p">)</span>
</code></pre></div></div>
<p>The code transforms the text before sending it, so it will work
without changes in the IRC client of the other person, supposed
control characters is supported of course. If you want to send/receive
text literally, just disable control characters interpretation with
<kbd>C-c C-c</kbd> in the ERC buffer.</p>
http://davazp.net/2012/12/08/eulex-forth-implementationI wrote a Forth implementation for x862012-12-08T00:00:00+00:002012-12-08T00:00:00+00:00David Vázquez/2012/12/08/eulex-forth-implementation<p>Yes, I did it, and I have to say that it was one of the most exciting
hack experiences that I have had. But let us start in the beginning,
four years ago. At that time, a friend and I was writing some toys
related to operating systems. He was a C programmer, but knowing that
nobody even will try our system, I wanted to have some extra fun! I
convinced him to embed a Forth in the kernel. I did not know anything
about Forth, but it promised to be interesting. I picked up
<a href="https://mywebspace.wisc.edu/lnmaurer/web/forth/Forth-79.pdf">an old specification of the Forth language</a>
and implement it in assembler for x86. It became a retro-software
project. However, he moved to other projects and the project stopped.</p>
<p>A couple of years later, I found the code again. I have not any other
thing to work in, so I chose to give it a try. I ported my original
implementation to 32 bits and I integrated the Forth implementation
with the C kernel. Once that I could write programs on it, I replaced
C and grew the language with many words. I wrote output routines, a
serial driver, keyboard and a video driver, memory management,
exceptions, timer… It was so fun that I could not stop there and I
wrote a speaker driver, an assembler and disassembler, trace/untrace
utilities, a Sokoban game taken from
<a href="http://www.gnu.org/software/gforth/">GForth</a>, emacs keybindings and
autocompletion in the terminal like in readline, and a simple Lisp
interpreter! Did I say how great growing the system from scratch was?</p>
<h3 id="try-eulex">Try Eulex</h3>
<p>The first thing you have to do is make sure you have a recent Qemu
installation. It has to be enough recent to support multiboot
kernels. Just installing the version of your distribution should
work. Now, get the source code from the repository</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone https://github.com/davazp/eulex.git
</code></pre></div></div>
<p>Move to the directory where it was cloned and type <code class="language-plaintext highlighter-rouge">make</code> to
compile. In order to launch QEmu with the Eulex image, run the script
<code class="language-plaintext highlighter-rouge">./run-eulex.sh</code>. If you pass any argument to this script, they are
passed to QEmu. It can be useful to enable sound, for example.</p>
<p>At this point, the system should boot as below. You can type Forth
code right there and it will be evaluated. Indeed, you can type TAB
key to autocomplete words, or use some emacs-like keybindings, e.g:</p>
<p><kbd>C-a</kbd>, <kbd>C-e</kbd>, <kbd>M-b</kbd>, <kbd>M-f</kbd>, <kbd>C-l</kbd>…</p>
<p><img src="/img/eulex/1.png" alt="eulex-screen-1" /></p>
<p>By default, the context provides standard Forth words, but if you want
to hack the internals you will need access to the internal
vocabulary. Use the word <code class="language-plaintext highlighter-rouge">eulex</code> to do that. You can try to type
<code class="language-plaintext highlighter-rouge">words</code> to list all the words in a context. In the internal
vocabulary, there are about a thousand words.</p>
<p>It is possible to disassemble words, e.g: <code class="language-plaintext highlighter-rouge">see edit-line</code>. Note that
the disassembler uses the current context to look call addresses back
into word names. If many addresses are not showing, try moving to the
eulex vocabulary.</p>
<p><img src="/img/eulex/2.png" alt="eulex-screen-2" /></p>
<p>There is not persistent storage, after halting QEmu, or rebooting with
the command <code class="language-plaintext highlighter-rouge">reboot</code>, changes will be lost. Therefore, you could want
to write code in the file <code class="language-plaintext highlighter-rouge">eulexrc.fs</code>, which is loaded automatically
when the system starts.</p>
<p>In closing, I would like to include a couple of nice pictures. The
first one is an incomplete screen block
<a href="https://github.com/davazp/eulex/blob/master/editor.fs">editor</a>,</p>
<p><img src="/img/eulex/3.png" alt="eulex-screen-3" /></p>
<p>The second one is a
<a href="https://github.com/davazp/eulex/blob/master/lisp/lisp.fs">little Lisp interpreter</a>,
written in Forth.</p>
<p><img src="/img/eulex/4.png" alt="eulex-screen-3" /></p>
<p>I hope you liked it. If you fancy hacking this and enjoy it as I did,
do not hesitate to write to me, I will help you with pleasure. There
many minor details, if you would like to try it but no to spend so
much time. If you feel adventurous, then the points to work are:</p>
<ul>
<li>
<p><strong>Bootstrapping</strong> <br />
Rewriting forth.S as a crosscompiler to run on GForth, the 100% of the
code would be Forth. The system could compile itself eventually. The
<a href="https://github.com/davazp/eulex/blob/master/assembler.fs">assembler</a>
I wrote can be used to this task, as it executes both in Eulex as in
GForth.</p>
</li>
<li>
<p><strong>Improving the compiler</strong> <br />
It is as native as described in this document. Code is very
inefficient. We could optimize it, but we do not want if the compiler
is written in assembler. So bootstraping should come first.</p>
</li>
<li>
<p><strong>Hard disk driver and FAT implementation.</strong> <br />
Actually, files are stored built-in with the same Eulex image, so they
are read-only.</p>
</li>
<li>
<p><strong>Dumping and restoring the world</strong> <br />
When the floppy driver or a file system implementation is working,
dumping the dictionary to the disk would have the nice effect ot
saving the whole state of the system.</p>
</li>
</ul>
http://davazp.net/2012/12/01/First-postFirst post2012-12-01T00:00:00+00:002012-12-01T00:00:00+00:00David Vázquez/2012/12/01/First-post<p>Hello everybody. Here it is, a new github-hosted blog. You can know
something <a href="/about.html">about me</a> now, but what will this blog be
about? Unsurprisingly, I will tell different things I hack, as the
main reason to open this blog is because I do not know many people to
talk about this kind of things face-to-face. You will find some Lisp
and Emacs-related posts probably, as well as some light math, but I
will post anything I find interesting.</p>
<p>The blog is quite simple. I do not provide tags yet, but I have
enabled comments on the posts, so you can give some feedback.</p>
<p>Finally, I hope to share some nice things, and somebody likes
it. Also, English is not my mother tongue, so writing it requires some
extra effort, but I will do my best.</p>
<p>Welcome to my blog.</p>