Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 5:01
provide any LISP macro with clear explanation of its structure and function
that is :
1.concise (max 10 lines)
2.does not have a C equivalent(at least not anything above 100 lines)
3.does not use any libraries or imported complex functions which are not in C
If you provide an exact explanation/commentary on what it does i'll try to make a C solution which
is equivalent to LISP one. If i fail to do so, LISP wins, if i provide a solution you can make another macro.
If all examples in the thread are provide with C equivalents, LISP loses.
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 5:12
>>2
Well, main selling point of LISP = Powerful macro system. Show some of that power.
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 5:18
If provided C macro is obviously inferior it would show how superior and elegant LISP syntax is(wtihout judgement on performance):
If there is no clear way to accomplish some LISP macro it would show a deficiency in C
If the LISP macro is easily translated into C preprocessor, it would make C superior.
If the LISP macro requires a complex C hack or multiple C function calls, this would also showcase simplicity of LISP.
Name:
Anonymous2011-12-08 5:32
Regular expression matcher macro, which compiles to machine code.
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 5:37
>>5
provide LISP code with clear and exact explanation of what it does.
Don't provide abstract examples or claims or LISP superiority.
>>3
nope, it is elegancy. writing in LISP more like an art than programming.
also not sure about what you mean by "lines". LISP code is basically a single line.
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 5:40
>>5
also, C file(with regex library) can produce a C output file(fprintf result strings) which would be compiled as second stage
system("compiler -flags output.c")
Its not complex just awkward.
Name:
Anonymous2011-12-08 5:45
hey frozenfurfag if you want people to like you here do something awesome like port the code into a simple turing-equivalent cellular automaton or something.
no one cares if you can rewrite code in C.
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 5:46
>>5 it would work like this:
1.C code produces Output.C using regexes and string parsing functions.
2.C code calls compiler to compile output.c to output.exe
3.control is transffered to output.exe,C code stops.
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 6:06
>>13
In some cases you may want to compile and load dynamically object files like tiny .dll's or .o files into the parent process executable space,
but they all require calling the compiler at least once(to produce the executable object file: it may be even 1 function long).
Anyway i've not seen any clear example of LISP macro which does something exclusive to LISP, so i could compare and propose an equivalent(which could even not use regexes or some complex features, just C code).
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 6:17
>>15
Not that, show something which is requiring to writing a page of code to work to replicate a line of LISP.
Even better: show equivalent "ugly" C code vs "elegant" LISP code, so i could try to rewrite it in far less space.
Name:
Anonymous2011-12-08 6:28
Inb4 Frozen writes a horrible LISP interpreter inside C
Name:
Anonymous2011-12-08 6:30
Executable XML users challenge?
Name:
Anonymous2011-12-08 6:31
It's not spelled ``LISP''.
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 6:33
>>17
I wouldn't write any run-time based code. Its very counterproductive to achieving any performance.
Compilation always has an advantage since it it not limited in time: a 1 hour compilation of an executable will outperform interpreted file which cannot spend time to interpret and optimize much, since it has to run at real-time.
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 6:44
>>22
I don't see anything wrong with the C code, here is equivalent macro
#define sort(array,function) qsort(array, sizeof(array)/sizeof(array[0]), sizeof(array[0]),function)
#include <stdio.h>
#include <stdlib.h>
int comparator(const void *num1, const void *num2) {
return *(const int *)num1 - *(const int *)num2;}
int comparator2(const void *num1, const void *num2) {
return *(const int *)num2 - *(const int *)num1;}
int main(int argn, char *args[]){
int arr1[] = {6, 5, 8, 1, 10, 4};
int arr2[] = {6, 5, 8, 1, 10, 4};
int i;
sort(arr1,comparator);
for(i=0; i<(int)(sizeof(arr1)/sizeof(int)); i++) printf("%d ", arr1[i]);
printf("\n");
sort(arr2,comparator2);
for(i=0; i<(int)(sizeof(arr2)/sizeof(int)); i++) printf("%d ", arr2[i]);
>>23
except that it is ugly as shit and huge comparing to lisp version? seriously, in lisp you simply say "sort" and give an array and a comparison operator and viola. in C you are surrounded with type casting, stupid tricks like sizeof a/sizeof *a, had to redefine a simple comparison operator etc
Name:
F r o z e n V o i d !!mJCwdV5J0Xy2A212011-12-08 6:52
is it pretty now?
#define STDMAIN int main(int argc,char**argv){;
#define STDEND ;return 0;};
typedef unsigned int u4;
u4 i;
#define sort(array,function) qsort(array, sizeof(array)/sizeof(array[0]), sizeof(array[0]),function)
#define printints(array) ;for(i=0;i<(sizeof(array)/sizeof(array[0]));i++){printf("%d ",array[i]);};puts("");
#include <stdio.h>
#include <stdlib.h>
int comparator(const void *num1, const void *num2) {
return *(const int *)num1 - *(const int *)num2;}
int comparator2(const void *num1, const void *num2) {
return *(const int *)num2 - *(const int *)num1;}
STDMAIN
u4 arr1[] = {6, 5, 8, 1, 10, 4};
u4 arr2[] = {6, 5, 8, 1, 10, 4};
sort(arr1,comparator);printints(arr1);
sort(arr2,comparator2);printints(arr2);
STDEND
(defmacro once-only ((&rest names) &body body)
(let ((gensyms (loop for n in names collect (gensym))))
`(let (,@(loop for g in gensyms collect `(,g (gensym))))
`(let (,,@(loop for g in gensyms for n in names collect ``(,,g ,,n)))
,(let (,@(loop for n in names for g in gensyms collect `(,n ,g)))
,@body)))))
Used in other macros to make sure arguments are only evaluated once. For example:
(defmacro m1 (x)
`(+ ,x ,x))
(m1 (f)) expands to (+ (f) (f)).
(defmacro m2 (x)
(once-only (x)
`(+ ,x ,x)))
(m2 (f)) expands to something equivalent to (let ((y (f))) (+ y y)).
Ok, I want you to implement a special sorting algorithm. in this algorithm you will implement a list with floating point numbers and integers. return a list that floating point at the beginning and sorted, after that sorted odd numbers and finally sorted even numbers. oh and append "hello world" to end of the list