In DrRacket mark the section (with shift+arrows) then use tab or shift+tab.
HN user
soegaard
Looks like a real conference - but the first thing you see is a large image of Rick Astley ?!
I LOATHE the fact that you traverse lists and vectors in completely different ways
In Racket:
(for ([x xs]) (displayln x))
This works for `xs` being a sequence, which includes lists and vectors.Making the type explicit generates faster code:
(for ([x (in-list xs)]) (displayln x))
(for ([x (in-vector xs)]) (displayln x))The version Microsoft used is discontinued. However, you can just buy a license of the new product.
Agree. It got the ball rolling.
Don't you need parens here?
(local.get 0)
(local.get 1)FWIW if you are looking for examples of WebAssembly written in the textual format, take a look at:
https://raw.githubusercontent.com/soegaard/webracket/refs/he...
As a small example, here is a definition of `$car` which extracts the first value from a pair.
(func $car (type $Prim1)
(param $v (ref eq))
(result (ref eq))
(if (result (ref eq))
(ref.test (ref $Pair) (local.get $v))
(then (struct.get $Pair $a (ref.cast (ref $Pair) (local.get $v))))
(else (call $raise-pair-expected (local.get $v))
(unreachable))))This was a great article and inspired me to add support for binary files in `peek`.
https://soegaard.github.io/peek/#%28part._binary-files%29
For me the key insight is that similar values should get similar colors. And since Fx and 0x are "similar" the color palette should be cyclic.
Yes.
Nanopass uses structures internally to represent the programs.
The Nanopass dsl just gives the user a nicer syntax to specify the transformations.
An Incremental Approach to Compiler Construction
Abdulaziz Ghuloum
http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf
Abstract
Compilers are perceived to be magical artifacts, carefully crafted by the wizards, and unfathomable by the mere mortals. Books on compilers are better described as wizard-talk: written by and for a clique of all-knowing practitioners. Real-life compilers are too complex to serve as an educational tool. And the gap between real-life compilers and the educational toy compilers is too wide. The novice compiler writer stands puzzled facing an impenetrable barrier, “better write an interpreter instead.”
The goal of this paper is to break that barrier. We show that building a compiler can be as easy as building an interpreter. The compiler we construct accepts a large subset of the Scheme programming language and produces assembly code for the Intel-x86 architecture, the dominant architecture of personal computing. The development of the compiler is broken into many small incremental steps. Every step yields a fully working compiler for a progressively expanding subset of Scheme. Every compiler step produces real assembly code that can be assembled then executed directly by the hardware. We assume that the reader is familiar with the basic computer architecture: its components and execution model. Detailed knowledge of the Intel-x86 architecture is not required.
The development of the compiler is described in detail in an extended tutorial. Supporting material for the tutorial such as an automated testing facility coupled with a comprehensive test suite are provided with the tutorial. It is our hope that current and future implementors of Scheme find in this paper the motivation for developing high-performance compilers and the means for achieving that goal.
I misread it too.
Loved the examples!
This is pretty small.
http://scheme.dk/blog/2006/12/self-evaluating-evaluator.html
If you are into continuations, check Friedman's papers on ReadScheme.
https://github.com/schemedoc/bibliography/blob/master/page6....
In particular look at "Programming with Continuations", "Engines Build Process Abstractions" and "Continuations and Coroutines".
I need to study the stack-switching proposal in more detail.
However, I don't see an obvious way of attach and probe continuation marks to the continuations (including the current one).
I am not an expert in continuation marks, so I'll just link to this presentation by Matthew Flatt (which you probably already know).
https://github.com/WebAssembly/meetings/blob/main/stack/2021...
Yes. I am following the Scheme tradition of representing immediate values as tagged pointers. And (ref i31) is the obvious choice when using WebAssembly. I am happy you and the team added GC to WebAssembly.
Details on the representation.
https://github.com/soegaard/webracket/blob/main/compiler.rkt...
I am more or less only using the linear memory for the JavaScript FFI. FASL-encoded values are passed back and forth to JavaScript.
Is Racket bytecode different?
Changes to the bytecode representation were indeed rare also in Racket.
The Whalesong project was written as part of a dissertation - and when people graduate and get jobs, projects are often abandoned.
I am using a similar representation of immediates as Hoot and wasm_of_ocaml.
The representation is explained here:
https://github.com/soegaard/webracket/blob/main/compiler.rkt...
Internally the compiler uses a series of passes implemented using Nanopass.
(generate-code
(flatten-begin
(closure-conversion
(anormalize
(categorize-applications
(assignment-conversion
(α-rename
(explicit-case-lambda
(explicit-begin
(convert-quotations
(infer-names
(flatten-topbegin
(parse
(unexpand
(topexpand stx)))))))))))))))
The code generator is inspired by "Destination-driven Code Generation"
by Dybvig, Hieb and Butler. There are some differences however. The code
generator in the paper generates "flat" code (assembler) whereas I
generate nested Web Assembly instructions.This approach generates reasonable code without having to implement a register allocator. Also, I believe I saw a Wasm to Wasm compiler that improved register allocation (maybe it was a switch for wasm-tools?).
If (when?) WebRacket becomes a success, we can always switch out individual passes.
Maybe. My main problem is to get light-weight support for continuation marks.
If I need a CPS-pass for continuation marks, I might as well use it for continuations as well.
It would be great if it were possible to avoid a CPS-pass though.
I wouldn't say compiling full Racket to WebAssembly is impossible. But I think the consensus is that one can't add a WebAssembly backend to the compiler in the same manner as the x86 and arm backends. These backends manipulate the stack in ways WebAssembly prohibits.
This forces an Racket implementation to make continuations explicit. And that will most likely mean a WebAssembly backend will be slower than the native backends.
Hi All,
It's still early days for the WebRacket project.
Racket is a huge language, so be patient wrt features.
To keep motivation high I decided to implement a subset that can be used to built practical applications - and then extend the supported features from there. Hopefully, this strategy will also lead to some early adopters that can help me prioritize which features to add.
Some features are simply "more of the same". In this category falls more types of hash tables. Supporting bignums are also a matter of just doing it.
Other features require more work. I have already done some work on implementing modules in terms of linklets. When linklets/modules work, we can reuse the existing implementation of regular expressions.
Adding continuation marks and delimited continuations require adding a CPS-pass. This is certainly doable. Postponing it has been great though. Having a direct style compiler means the generated code follows the structure in the input source code. And that makes debugging easier. Now that bugs have become rarer, it makes sense to look at CPS.
Enjoy.
/Jens Axel
No, there is nothing in common with Whalesong.
Whalesong used the built-in bytecode compiler and compiled the bytecode to JavaScript. Reusing the bytecode compiler is in principle a good idea - but each time the bytecodes are changed, Whalesong needs to be updated.
And after the move to Chez Scheme as backend, the bytecode compiler is no longer a part of the main compilation path.
Nato - Article 2
The Parties will contribute toward the further development of peaceful and friendly international relations by strengthening their free institutions, by bringing about a better understanding of the principles upon which these institutions are founded, and by promoting conditions of stability and well-being. They will seek to eliminate conflict in their international economic policies and will encourage economic collaboration between any or all of them.
A wonderful video!
From the Idris 2 documentation:
>> Can Idris 2 compile itself?
> Yes, Idris 2 is implemented in Idris 2. By default, it targets Chez Scheme,
> so you can bootstrap from the generated Scheme code, as described in Section
> Getting Started.
Also, check this talk:Go to racket-mode.com for the very nice Emacs-integration.
I think, this is the best way of running the SICM programs.