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;
}
>>1
bigloo has type signatures like that. I think defmethod style signatures are better, since you can write lisp style macros that expand to them.
Name:
Anonymous2013-08-01 2:59
>>4 defmethod style signatures are better, since you can write lisp style macros that expand to them.
typename:varname dont impede macros. Moreover, they provide strong typing with (intern varname "typename") being constructor, while symbol-package and symbol-string are accessors.
Name:
Anonymous2013-08-01 3:08
>>5
The power of lisp macros comes from every element of its syntax being parsable as a tree data structure. If this syntax sugar was allowed, how would macros expand to it, and would you be able to pass the variable:type form as arguments to macros that expanded to function definitions?
and more importantly, would macros be able to inspect the variable:type form using accessor methods?
Name:
Anonymous2013-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;
}
}
>>8
It would be also nice to add string constructor sugar, which would automagically expand "point = ([x],[y])" into `sprintf tmpbuf "point = (%d,%d)" x y`. It would save so many keystrokes!
Name:
Anonymous2013-08-01 3:59
hey nikita, you are so smart. would you like to lose your virginity to me? i'm a girl btw <3 :3
>>7
typename:varname transparently solves major compiler micromanagement problem with well known tools, so that all type info would be available to user and READ would refuse to accept undefined types, while still allowing forward declarations.
Name:
Anonymous2013-08-01 8:02
Accessing struct fields could also be done with apply notation: (file buffer length) instead of file.buffer.length
My code doesnt compile!
failed AVER: (NULL CURRENT)
This is probably a bug in SBCL itself. (Alternatively, SBCL
might have been corrupted by bad user code, e.g. by an undefined
Lisp operation like (FMAKUNBOUND 'COMPILE), or by stray pointers
from alien code or from unsafe Lisp code; or there might be a
bug in the OS or hardware that SBCL is running on.) If it seems
to be a bug in SBCL itself, the maintainers would like to know
about it. Bug reports are welcome on the SBCL mailing lists,
which you can find at <http://sbcl.sourceforge.net/>;.
[Condition of type SB-INT:BUG]
Name:
Anonymous2013-08-01 15:34
>>39
That is some crazy bug. It fails on (match 123 ((= x (not (x ! oddp x))) (list 'hello x)))
but it works when I macroexapand it to:
(LET ((G996 123))
(BLOCK G997
(TAGBODY
(LET ((X G996))
(LET ((G999 G996))
(BLOCK G1000
(TAGBODY
(LET ((X G999))
(IF (ODDP X)
(RETURN-FROM G1000 (PROGN (GO G998)))
(GO G1002)))
G1002
(RETURN-FROM G1000
(PROGN (RETURN-FROM G997 (PROGN (LIST 'HELLO X)))))
G1001))))
G998)))