RSS

C is weakly typed. Lisp is strongly typed.

30 Jul

Not düşeyim bir kenara, epey güldürmüştü beni vakti zamanında.

C is weakly typed.
LISP is strongly typed.

diye konuya girmiş olan Pascal Bourguignon şöyle devam etmiş:

“In C:


% cat b.c
#include 
int main(int argc,char** argv){
   printf("%sn",argv[1]+42);
   return(0);
}

% make -k b
make: `b' is up to date.
% ./b xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxx
% ./b xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyyy
yyyyyyyyy
% ./b
Segmentation fault

On the other hand, in LISP:

[203]> (+ "hello world" 42)

*** - +: "hello world" is not a number
The following restarts are available:
USE-VALUE      :R1      You may input a value to be used instead.
ABORT          :R2      ABORT
Break 1 [204]> :q
[205]> (compile nil (lambda () (+ "Hello" 42)))
WARNING :
Arithmetic operand "Hello" must evaluate to a number, not "Hello"
WARNING :
Run time error expected: +: "Hello" is not a number

# ;
2 ;
2

Advertisements
 
Leave a comment

Posted by on July 30, 2006 in General, Lisp, Programlama

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: