Arc Forumnew | comments | leaders | submit | stefano's commentslogin
2 points by stefano 6526 days ago | link | parent | on: Problem displaying images

I completely agree.

-----


This seems more suitable for an imperative style of programming, whereas Arc tends to prefer functional style (no side effects), but it's just a matter of personal taste.

-----

3 points by slashcom 6526 days ago | link

Regardless, it's extremely useful in the REPL. Instead of inlining the previous expression, you can just use 'that.

-----

0 points by stefano 6527 days ago | link | parent | on: arc-to-c : soon on the git

You have to be sure that every allocated object is at 8 byte boundaries for the pointer to end with 00.

-----

1 point by stefano 6527 days ago | link | parent | on: arc-to-c : soon on the git

Making a fixnum a pointer to a allocated memory containing the value is terribly slow.

The infinite loop could be caused by two objects that references each other, e.g. a references b and b references a, so the GC keeps going from a to b and from b to a. To solve the problem, if this is the problem, if an object has been already marked, don't follow it.

Note: I've not read the source yet.

-----

3 points by stefano 6528 days ago | link | parent | on: arc-to-c : soon on the git

Attaching too much information to an object leads to serious problems. Think about fixnums: they're usually implemented using 2 bits out of 32 as a type tag. This way you don't have to allocate them on the heap. If you attach an extra information you have to put everything on the heap (very slow for fixnums).

As of collections-in-function-position instead of returningm for example, and hash-table one could return a fuction that acts as an interface towards the real hash-table.

  (def table () 
    (let tb (make-real-table)
      (fn (key) (gethash tb key))))
This doesn't handle setting values, but I think that a few macros could solve the problem.

-----

2 points by almkglor 6528 days ago | link

> Attaching too much information to an object leads to serious problems. Think about fixnums: they're usually implemented using 2 bits out of 32 as a type tag. This way you don't have to allocate them on the heap. If you attach an extra information you have to put everything on the heap (very slow for fixnums).

Then let's not attach both types to the same object. pg's implementation creates a new object and attaches the type to that object, leaving the original representation object (type id and all) untouched. Basically we have an annotation type which just contains the attached type and the original object, leaving the type id bits untouched.

> This doesn't handle setting values, but I think that a few macros could solve the problem.

Looks like a job for settable-fn ^^

-----

3 points by sacado 6528 days ago | link

Yes. I implemented fixnums with the last bit as a tag-bit. If it's 0, everything else is a fixnum. If not, well, it's something else... Maybe nil, t or a reference to something else.

Your idea for callable collections seems quite good, too. But I'm not there yet.

-----

1 point by stefano 6528 days ago | link | parent | on: arc-to-c : soon on the git

Wow. I can't wait. I'm also writing a compiler following this tutorial: http://www.cs.indiana.edu/~aghuloum/compilers-tutorial-2006-... but it's just an exercise.

-----

1 point by stefano 6531 days ago | link | parent | on: An idea for Arc in Arc

Some compilers are not metacircular, so you could skip the first part and pass directly to the second. The difficulty depends on the knowledge of the compiler you want to modify. Anyway, this seems a rather difficult task.

-----

1 point by eds 6531 days ago | link

> The difficulty depends on the knowledge of the compiler you want to modify.

And since I don't know Scheme implementations that well, I'd appreciate any advice on which compilers might be suitable for this project.

-----

1 point by stefano 6530 days ago | link

Ikarus seems to be self-hosting.

-----

1 point by stefano 6531 days ago | link | parent | on: CL-Arc: Arc Compiler in Common Lisp

You can trust CL to do tail recursion. I'm not sure if the standard requires it but every decent implementation must provide it.

-----

2 points by eds 6531 days ago | link

I think I'll just say that CL-Arc is only compatible with the subset of CL implementation that do tail recursion. (Which happens to be all the implementations I would consider using anyways.)

-----

3 points by stefano 6531 days ago | link | parent | on: CL-Arc: Arc Compiler in Common Lisp

CL reader is highly extendable and you can tell it to be case sensitive: (setf (readtable-case readtable) 'sensitive), if I remember correctly. It's possible, I think, to use it to read Arc code.

-----

1 point by eds 6531 days ago | link

Is this portable?

But assuming it works in some form or other, it should remove most of the need to write a custom reader. Though there is still the issue of (for example) complex number syntax, etc.

-----

3 points by stefano 6531 days ago | link

It's in the standard (CLTL2). You can fix everything, because you can tell the reader to use your own functions on particulars characters, as an example this is a piece of code that lets you use Arc [... _ ...] syntax in Common Lisp:

(defun read-square (stream c) (declare (ignore c)) (let ((body (read-delimited-list #\] stream t))) `#'(lambda (_) ,body)))

(set-macro-character #\] #'(lambda (x y) (declare (ignore x y)) (values))) (set-macro-character #\[ #'read-square)

-----

1 point by stefano 6531 days ago | link | parent | on: CL-Arc: Arc Compiler in Common Lisp

FFI should be almost immediate (a few days) using CFFI. You should also have a look at ac.sbcl.lisp on Anarki as a starting point.

-----

1 point by eds 6531 days ago | link

That's the problem though: if this isn't a full summer's worth of work it isn't really a valid project for GSoC.

-----

2 points by stefano 6531 days ago | link

You could add to the proposal various useful libraries, such as libraries to use HTTP, FTP, SMTP, etc. protocols, bindings to access databases, graphic libraries, etc. You just have to choose.

-----

More