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

Replacing C/C++ with LISP.

Name: Anonymous 2013-08-01 2:32

Consider the following way to use Common Lisp in place of C/C++, without any custom reader macros:

(to main int:arg char:argv
  ! printf "Hello, World!"
  ! return 0
  )


I.e. packages take role of builtin types and structs, also containing definition for overloadable `+` and `-` and template generics, so a compiler could be implemented without much fuzz, using already present Common Lisp framework.

It would also look much clearer than standard C/C++:
int main(int argc, char **argv) {
  printf ("Hello, World!");
  return 0;
}

Name: Anonymous 2013-08-01 3:18

And because compiler knows types, we can reuse function application for array indexing, so a[i][j] would be (a i j). '=' would be declaration and ':=' (pascal style) setf. Resulting code would be no less readable than the original C/C++ version:
(to 'char:basename 'char:name
  ! long:i = - (strlen name) 1
  ! while (and (!= (name i) #\/) (> i 0))
     dec i
  ! when (== i 0) return ""
  ! name i := 0
  ! return name
  )


char *basename( char *name ) {
   long i;

   for( i = strlen( name ) - 1; (name[ i ] != '/') && (i > 0); i-- );

   if( i == 0 )
      return "";
   else {
      name[ i ] = 0;
      return name;
   }
}

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