Hacker News new | past | comments | ask | show | jobs | submit login

> But this means that `cond` is not a function anymore because it could be that > A popular notion is that Lisp has no syntax. People also say Lisp's syntax is just the one rule: everything is a list expression whose first element is the function/operator and the rest are its args.

That's wrong. Lisp has functions, special operators (like IF) and macros. Also any data-object is also valid Lisp.

Valid Lisp examples:

    3          -> number
    "string"   ->
    hello      -> variable
    (print "hello world")  -> function call
special forms

    (if (> a 10) 1 0)      -> no more than three args,
                              arg 2 & 3 are evaluated depending on first argument value

    (let ((var1 20)        -> definition of local variables
          (var2 22))
      (+ var1 var2))

    (quote hello)          -> definition of a literal object
macros

    (defun foo (arg1 arg2)       -> defun is macro, which defines global functions
      (if (> arg1 arg2)
          1
          0))
> But this means that `cond` is not a function anymore because it could be that for two different inputs, it returns the same output.

A function can return the same output for different inputs.

    (defun foo (args)
      0)
Above returns 0 for all arguments. It's a valid function.

> So essentially, my understanding so far is that Lisp has list expressions, but what goes on inside those expressions is not necessarily following one unifying syntax ruleā€”it actually follows many rules. And things get more complicated when we throw macros in the mix: Now we have the ability to have literally any syntax within the confines of the list expressions, infinite syntax!

That's true.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: