Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

I wish to reach satori

Name: Anonymous 2012-01-22 14:05

I want to make my own compiler that does Common Lisp or a subset of it to MIPs assembly or any other elegant asm.

How hard would this be?

Name: Anonymous 2012-01-22 14:17

130 HV

Name: Anonymous 2012-01-22 14:20

>>1
Why did you not capitalize the "S"?

Name: Anonymous 2012-01-22 14:28

Create a Deutsch-Schorr-Waite garbage collector.

Name: Anonymous 2012-01-22 14:33

Depends how non-toy you want to make your implementation. Serious CL implementations aren't always small (something over 30MB+), but they do target many platforms and have a lot of interoperability/extensions to regular CL.
What most people that want to make a toy Lispy compiler tend to do is just pick some R5RS (or lesser) Scheme and implement that as it's a lot less work.

Name: Anonymous 2012-01-22 14:35

The subset is easy.

Name: Anonymous 2012-01-22 14:36

What if I make a CL subset that relies on manual memory management

Name: Anonymous 2012-01-22 14:43

>>7
No, I'm just not seeing t

(let ((anus (malloc 4))
   (print anus)
   (print (ptr-to-int32 anus 0))

Name: Anonymous 2012-01-22 14:47

>>8

fixed:


(let ((anus (sizeof 'int32))
   (print anus)
   (print (ptr-to-int32 anus 0))
   (free anus))

Name: Anonymous 2012-01-22 14:48

woops.

(let ((anus (malloc (sizeof 'int32)))
   (assert anus)
   (print anus)
   (print (ptr-to-int32 anus 0))
   (free anus))

Name: Anonymous 2012-01-22 14:53

>>10
that looks weird still since you free within the let.

(let ...) should only be stack allocation

manual memory should just be simply:

(set anus (malloc (sizeof 'int32)))
(assert anus)
(print anus)
(print (ptr-to-int32 anus 0))
(free anus)


some sort of set to distinguish between stack and heap

Name: Anonymous 2012-01-22 14:59

>>7
There's already movitz which has a lot of inline x86 asm.

Name: Anonymous 2012-01-22 15:00

>>11
the let makes sense: you're allocating the address(x bytes) returned by malloc onto the stack with a variable called anus.

calling free will clear the heap you allocated and then after the let is finished the address on the stack that was saved to anus `goes away'.

Name: Anonymous 2012-01-22 15:00

>>12
any other elegant asm
x86 isn't elegant

Name: Anonymous 2012-01-22 15:06

>>14
I suppose you're right. Enjoy writing your toy(?) implementation and try not to make it too awkward if you really insist on making a C in Lisp clothing out of it.

Name: Anonymous 2012-01-22 15:40

Lisp minus parens isn't shit.

Name: Anonymous 2012-01-22 15:45

>>16
parens make lisp pretty easy to parse tbh

Name: Anonymous 2012-01-22 15:46

>>17
By a computer, but not by a human.

Name: Anonymous 2012-01-22 15:49

>>18
it just has a initial learning curve.

plus you only find it hard because no other language really does it and thus you're not used to it.

Name: Anonymous 2012-01-22 16:20

>>18
I read Lisp quite fine thank you. Takes about a week to get used to, after that it's as easy as natural languages.

Name: Anonymous 2012-01-22 16:21

fogagt

Name: Anonymous 2012-01-22 16:22

>>18
By a computer, but not by a human.

'((that is the point)

  (in lisp |,| you cannot just consider the first level
   interpretation of the code |,| as it is the priority
   in lesser languages |,| but also make it easier for
   the programmer to conceptualize an abstract system that
   can transform code or other structured knowledge and an
   austere convention of structuring information to represent
   that code)

  (without this |,| lisp would fill the brain with unneeded
   shit known as syntax for the mental abstract system to
   contend with |,| and lisp loses its power)
  )

Name: Anonymous 2012-01-22 16:23

Satori my dubs

Name: Anonymous 2012-01-22 16:24

>>20

yeah, but then if you read code written by someone else who uses different coding conventions, or uses no indentation, you are totally screwed. It's still bad with curly brackets and semi colons of course, but those extra symbols help give some context to the reader in situations like that. But this can be solved with auto formaters.

Name: Anonymous 2012-01-22 16:28

>>19-20,22
It has a "syntax" (in a certain sense, defined by its various macros and special forms), but you have to see through the parens for it, which is fucking gay and ultimately destructive.

Name: Anonymous 2012-01-22 16:40

>>24
No, random mix-match of different symbols just makes shit batshit retarded to read when it's sloppy.

Name: Anonymous 2012-01-22 17:41

>>24
or uses no indentation,
Properly indenting any Lisp code out there is one keystroke away in any editor with a Lisp editing mode.

Properly formatting almost any Lisp code out there is one pretty-print call away in almost any usable Lisp implementation.

Don't change these.
Name: Email:
Entire Thread Thread List