Arc Forumnew | comments | leaders | submitlogin
4 points by almkglor 5964 days ago | link | parent

  char* x = (char*) 0xf80;
  int i;
  for(i = 0; i < 128; ++i, ++x){
      (*x) = (char)i;
  }


8 points by brucio 5963 days ago | link

  (let ((x (sb-sys:int-sap #xF80)))
    (dotimes (i 128)
      (setf (sb-sys:sap-ref-8 x i) i)))

-----

1 point by almkglor 5963 days ago | link

  typedef void fntype(int);
  ((fntype*)0xf80)(42);
^^

-----

3 points by brucio 5963 days ago | link

I'm guessing you're not familiar with SB-ALIEN.

-----

1 point by almkglor 5962 days ago | link

Well, you stumped me now^^

I guess Lisp wins then ^^

-----

1 point by bOR_ 5963 days ago | link

That one requires anarki?

-----

3 points by brucio 5963 days ago | link

It's SBCL, but the point is any serious Lisp will have the facility to do the same thing.

-----

1 point by rntz 5963 days ago | link

That depends on how you define "serious". I doubt there are many Schemes with the ability to write into arbitrary regions of memory.

-----

2 points by brucio 5963 days ago | link

Serious Schemes let you do this, or let you add it without much trouble.

-----

1 point by rntz 5962 days ago | link

Really? Can you list the lisps (common lisps, schemes, whatever) that let you do this kind of stuff? And tell me why the ones that don't aren't "serious", according to you?

-----

6 points by brucio 5962 days ago | link

SBCL, CMUCL, LispWorks, Allegro CL, CLISP, etc. make it easy.

I don't habitually use Scheme, but Rob Warnock used MzScheme for hardware debugging all the time; check google groups for "rob warnock scheme mmap".

Lisp is a general purpose programming language; no less so than C. If you can't do anything C can do with your Lisp, it's time to upgrade your Lisp.

-----

3 points by rntz 5952 days ago | link

So, according to you, Python isn't "general-purpose" and Haskell isn't "serious"? I could list many more languages here, of course, but my point is obvious.

It's useful to be able to do lowlevel bitflipping stuff, that I don't deny; and I am suitably impressed by the number of lisps that have put thought into allowing this. But just because a language lacks such capabilities doesn't mean I'd rather use C, or even Lisp! And often, if I'm really interested in lowlevel stuff, I'm also intimately concerned with things like speed and memory usage that I can't necessarily address even in a highly optimized lisp. For example, all lisps need GCs (what if I want to write a GC? I'd rather not have my GC itself need GC, and I'm not learned enough concerning the implementation of eg. SBCL to, like the writers of T, write a GC in it such that the GC needs no GCing), and any Common Lisp necessarily comes with a huge standard library attached.

-----

3 points by rntz 5963 days ago | link

I'm unclear. Is this supposed to demonstrate that Lisps can't write arbitrary regions of memory, or that Lisps don't segfault easily? :P

-----

2 points by brucio 5963 days ago | link

I don't know about your Lisps, but mine segfaults constantly. (It also handles the segfaults.)

-----