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

Executable XML users challenge

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-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: Anonymous 2011-12-09 7:21

>>160
Please, point a CPU without turing-completness.

Name: Anonymous 2011-12-09 7:22

>>161
Please, point a /prog/ thread without trolls.

Name: Anonymous 2011-12-09 7:26

>>162
Please, point a woman without a vagina.

Name: Anonymous 2011-12-09 7:27

Name: Anonymous 2011-12-09 7:57

Name: Anonymous 2011-12-09 8:57

Name: Anonymous 2011-12-09 8:58

Name: Anonymous 2011-12-09 9:04

Name: Anonymous 2011-12-09 9:12

Name: Anonymous 2011-12-09 9:37

>>169
Wikipedia does not have an article with this exact name. Please search for Most nigger mature in Wikipedia to check for alternative titles or spellings.

    * Search for "Most nigger mature" in existing articles.
    * Look for pages within Wikipedia that link to this title.

Name: Anonymous 2011-12-09 10:58

>>167
Sociological_and_cultural_aspects_of_autism
Even the title sounds autistic.

Name: Anonymous 2011-12-09 11:44

Serious failure from both sides. You guys just suck.
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.


There is nothing which states that a macro may be disqualified based on whether or not it is efficient, or that the idea behind the macro may or may not be coherent. The rules stated inside the original post are the only official rules.

Conclusion: C is shit. >>1-171 is a faggot.

Name: Anonymous 2011-12-09 13:32

Name: Anonymous 2011-12-09 16:55

>>173
In case you missed it, here is the central macro:
(define-syntax ck
  (syntax-rules (quote)
    ((ck () 'v) v)            ; yield the value on empty stack

    ((ck (((op ...) ea ...) . s) 'v)    ; re-focus on the other argument, ea
      (ck s "arg" (op ... 'v) ea ...))

    ((ck s "arg" (op va ...))        ; all arguments are evaluated,
      (op s va ...))            ; do the redex

    ((ck s "arg" (op ...) 'v ea1 ...)    ; optimization when the first ea
      (ck s "arg" (op ... 'v) ea1 ...)) ; was already a value

    ((ck s "arg" (op ...) ea ea1 ...)    ; focus on ea, to evaluate it
      (ck (((op ...) ea1 ...) . s) ea))

    ((ck s (op ea ...))            ; Focus: handling an application;
      (ck s "arg" (op) ea ...))        ; check if args are values
))

It's a continuation machine with a stack, mentioned originally in Programming Languages and Lambda Calculi, which eventually became the work Semantics Engineering with PLT Redex. Enjoy you are failure.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-10 3:44

>>174
I don't understand such abstract bullshit with such vague concepts as "continuation machine"
Explain it in C terms, not your Computer Science major-speak. I learned C and every programming technique on my own.

Name: Anonymous 2011-12-10 3:48

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-10 3:50

>>176
That not explaining anything. I want a clear and concise explanation, as i already stated in >>1
>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.

Name: Anonymous 2011-12-10 3:54

Do this one frozenvoid:


(defmacro (backwards-lol lis) (reverse lis))


This is a textbook example used to show lisp's generality with macros. It lets you write code backwards lol!


(defmacro backwards-lol (lis) (reverse lis))
#<unspecified>
(backwards-lol ("hi" display))
hi#<unspecified>
(backwards-lol ((newline) (display "The backwards ness isn't nested though.") begin))
The backwards ness isn't nested though.
#<unspecified>


Anyways, I'd like to see a proof of concept for it with C. I like pushing C's preprocessor to its limits.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-10 3:59

>>178
What exactly you want
1. code which reverse a string of code
2. code which reverse a string of text

Name: Anonymous 2011-12-10 4:00

I don't understand
Explain it in C terms
IHBT

Name: Anonymous 2011-12-10 4:02

>>179
code is text

Name: Anonymous 2011-12-10 4:04

(reverse '(1 2 3))
(3 2 1)

Name: not >>178 2011-12-10 4:06

>>179
1 is the case in >>178. The actual atom/elements of the macro are reversed before being passed to the compiler. In C, you need a lexer/parser to manipulate the AST like that. It's kind of an artificial example which has little use in practice, but I've written macros which did quite fancy code manipulations which are just not possible in text-substitution macro systems. The only way they would be possible is if you could hook/extend your C compiler within the actual program you're coding.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-10 4:16

>>181,183
In case of reversing a string of code this does make sense in C, code will be corrupted.
In case of reversing a string of text, this would be a trivial string function, not a macro.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-10 4:21

The process of reversing a string of text and sending it to compiler again is not complex either.
You just reverse a string of text, print it to file, and compile it.
Except it won't compile. Since reversing code will not be viable in C(C has real syntax, not textual soup of random words)and i can't find any practical example for the useless function i outlined above, and thus this code would not need to be written at all.

Name: Anonymous 2011-12-10 4:23

>>179

implement:


int c = 5;
BACKWARDS_LOL(c, "fuck da police because %d\n", printf)


I think the above has a chance of being done. Then try expressing:


int c = 0;
for(int i = 0; i < 11; ++i) {
  if(i&7) {
    ++c;
  }
  printf("%d: %d\n", i, c);
}


as:


BACKWARDS_LAWL(
{
  ;(c ,i ,"%d: %d\n")printf
  {
    ;c++
  }(7&i)if
} (i++ ;11 < i ;0 = i int)for
; 0 = c int
)

Name: not >>178 2011-12-10 4:24

>>184
In case of reversing a string of code this does make sense in C, code will be corrupted.
A C equivalent can be given that wouldn't result in corrupt code, but it's non-trivial, unlike the Lisp code as AST=S-Exp for Lisp. Imagine parsing the code into an AST, reversing the tree and outputting the C code. For example, one way would be to have it reverse the order of the expressions.
In case of reversing a string of text, this would be a trivial string function, not a macro.
Even if I accept that, a macro would generate the code corresponding to the reversed string. This is kind of doable in C, if you're fine with having your own preprocessor which generates C code. It's still more work than the Lisp equivalent (I'd write it as a reader macro which reverses some string after it (for example quoted) and then passes the string to the lexer/parser to be processed further).

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-10 4:31

>>186
>I think the above has a chance of being done.
I think you're deeply mistaken if i'm going to write macro for this, this is string processing function which would process text and output code.
However i'm not writing the backwards code in the first place, i would just writing the correct code, i would not any preprocessor bloat layer to write it.

Name: Anonymous 2011-12-10 4:33

>>185

It seems that you are giving up. It might not be practical to reverse arbitrary code, but it could be practical to do a similar traversal of the code and locate certain symbols, and do something special to them. Reversing the code is just showing that you can do it. Anything you can do to a list a run time, you can do to your code at compile time. There is no need to resort to FILE IO and recompilation, or scripts and tools to parse your program and generate code which you then link with. Both methods work, but less work and less complexity for the user is involved if it can all be integrated into the compiler by providing one syntactic tool in the language. Just think, what if someone could implement Qt using only ANSI C/C++, and all the QT meta object code generation was created by definitions within the language standard. Using Qt would be as easy to use and provide any other library.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-10 4:33

if you need a preprocessor for such problems as making your own toy language, you might want to write a complete toy language in the first place, which would be independent of Lisp.

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-10 4:37

>>189
There is no specific need to FILE IO, you could compile to a ram drive(which is done in cases when compilation is limited by disk)

Name: Anonymous 2011-12-10 4:38

>>190

If Qt is a toy language (extension), then what is a toy language?

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-10 4:40

Name: Anonymous 2011-12-10 4:41

>>191

If you are using a ram drive, you are still going through the operating system, and that is still file io. It just happens that you are not writing to a physical disk, or solid state device, or network file system, or a floppy drive.

What you could do is store the code in a buffer in the program's memory, and link the program with a library for a c compiler, and call a compile function on the buffer.

Name: Anonymous 2011-12-10 4:42

mai brai is brokn

Name: C is a toy language 2011-12-10 4:43

Because useful programs are so bloated!

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-10 4:44

You can even make your own optimized ramdrive too, even on windows(Microsoft provides source @ http://support.microsoft.com/kb/257405 )

Name: Anonymous 2011-12-10 4:47

cool stuff!

Name: F r o z e n V o i d !!mJCwdV5J0Xy2A21 2011-12-10 4:49

The process of replicating such Lisp code at maximum performance:
1.make optimized ramdrive, set it to store temporaries and compiler file paths.
2.open new C file on the ramdrive on notepad
3. write your retarded Lisp strings
4.call the compiler, run the result program->which will output second-stage program code.
5. Now after it compiled, your first program will stop waiting and transfer control to second program.

Name: Anonymous 2011-12-10 4:52

>>190
No, you wouldn't. Writing a DSL in CL takes me very little effort (a page or two of code for something trivial), while doing the full-fledged thing in C is much more worse than I'd ever want to spend my time on, thus like most good C users, we'd resort to hacks when writing it in C because we're lazy to do it properly and just do it properly when writing it in Lisp. That's one of the main differences between coding styles in C and Lisp. To be fair, there are techniques of doing certain such limited DSLs in C with little effort(examine the code of some high-quality, high-performance open source C applications/servers/clients to get some ideas, if you're not familiar with such techniques), but they are never easier than doing it in Lisp.

I'd understand doing it in C if you just hate Lisp, but for someone who finds it quite natural to write Lisp code, it will be the thing I'll reach for most of the time.
To give a practical example, I was looking at some fairly complex data (de)serialization code written in C++, many pages long and very dense and hard to read. A while ago I had written a more some more general library for handling such data (not intended for this use, it was purely general purpose), and a description for that data in my DSL took about a page of code and was very easy to read and understand  and the generated code just worked the first time I wrote it.

Obviously the mess/repetitive code solution is unacceptable for serious developers who cannot afford having to change dozens of files each time they commit trivial changes to some high-level description of their data (not to mention the risk of errors/bugs/vulnerabilities). How do serious developers like Google that insist on writing in popular languages (like C++) handle it? They make huge ENTERPRISE DSLs for describing their data (see: http://code.google.com/p/protobuf/downloads/list for an example, about 10MB of C++ code). To use such DSLs you have to run the compiler to generate the code for your description, which you can then use in your code (of course, you need to modify the build chain/makefile to call the code generator). It's not that Lisp macros wouldn't generate similar monsters (just look at the expansion), but the macros won't take 10MB of code just for a simple data description language DSL, and you won't have to run separate code generating utils as part of your build process. Of course, that was just one example, creating DSLs is very cheap in Lisp, and people do it all the time, which isn't a luxury you can afford in C-likes that much.

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