2011-05-22

Functional Programing: stop using recursion, cons. Use map & vectors

this is important but i think most lispers and functional programers still don't know it.

Functional Programing: stop using recursion, cons. Use map & vectors.

〈Guy Steele on Parallel Programing〉
http://xahlee.org/comp/Guy_Steele_parallel_computing.html

btw, lists (as cons, car, cdr) in the lisp world has always been some kinda cult. Like, if you are showing some code example and you happened to use lisp vector datatype and not cons (lists) and it doesn't really matter in your case, but some lisper will always rise up to bug you, either as innocent curious question or attacking you for not “understanding” lisp. (just as other idiocies happen in other lang that lispers see but other langs don't see)

it's interesting to me that all other high level langs: Mathematica, perl, python, php, javascript, all don't have linked list as lisp's list. It's also curious that somehow lispers never realises this. I've been having problems with lisp's cons ever since i'm learning Scheme Lisp in 1998 (but mostly the reason is language design at syntax and lack of abstraction level in calling “cons, car, cdr” stuff, without indexing mechanism). Realizing the algorithmic property and parallel-execution issues of linked list is only recent years.

Xah

2011-05-18

English Idiom in Unix: Directory Recursively

http://groups.google.com/group/comp.lang.python/browse_frm/thread/3702cd4e7d2c54c5/

Xah wrote:
〈English Idiom in Unix: Directory Recursively〉
http://xahlee.org/comp/idiom_directory_recursively.html

Mike Barnes wrote:
> Xah Lee :
>
> >For example, when you want to delete the whole dir in emacs, it
> >prompts this message: “Recursive delete of xx? (y or n) ”.
>
> AFAICS what emacs calls "recursive delete" is what the ordinary person
> would simply call "delete". Presumably the non-recursive delete is
> called simply "delete" but is actually something more complicated than
> delete, and you're supposed to know what that is.
>
> Also (I'm speculating) a recursive delete means carrying out the
> (ordinary, non-recursive) delete process on sub-directories,
> recursively. The result of which is, put simply, to delete the
> directory.
>
> I find all this somewhat arcane. Questioning the precise suitability of
> the word "recursive" seems like a quibble.

that's good point. I think what happens is that the “recursive” has become a idiom associated with directory to such a degree that the unix people don't know what the fuck they are talking about. They just simply use the word to go with directory whever they mean the whole directory.

In the emacs case: “Recursive delete of xx? (y or n) ”, what could it possibly mean by the word “recursive” there? Like, it might delete the directory but not delete all files in it?

also, in the rsync case: “This would recursively transfer all files from the directory … ”, what does the word “recursively” mean there?

Xah

2011-05-10

emacs autoload, auto-mode-alist, nxml-mode

the reason it nxml-mode is loaded when u call xml-mode is probably because there is a alias.

you can probably set it back by:

(defalias 'xml-mode 'sgml-xml-mode)

Peter wrote:
> (setq auto-mode-alist (cons '("\\.[XxRrMmDdTt][TtMmDdSsNnEe][PpAaMmLlFfSsIi]?[EePp]*[Cc]*$" . xml-mode) auto-mode-alist))

that seems to be pretty bad.

you probably want to use add-to-list instead of setq.
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))

also, the file suffix
"\\.[XxRrMmDdTt][TtMmDdSsNnEe][PpAaMmLlFfSsIi]?[EePp]*[Cc]*$"
seems quite wild. What is it?

nxml-mode is a new mode for xml, written by the xml expert James Clark, who is also the original author of sgml-mode (html-mode and xml-mode are parts of sgml-mode). nxml-mode features on-the-fly xml validation. It's 10k lines of elisp.

the following might provide helpful info:

〈How to Install Emacs Packages〉
http://xahlee.org/emacs/emacs_installing_packages.html

〈New Features in Emacs 23〉
http://xahlee.org/emacs/emacs23_features.html

Xah

On May 7, 3:45 pm, Peter Flynn wrote:
> I just upgraded a machine to Ubuntu Natty, which installed Emacs 23.2,
> which appears to open XML files in nxml-mode by default. My .emacs file says
>
> > (autoload 'xml-mode "psgml" "Major mode to edit XML files." t )
> > (setq auto-mode-alist (cons '("\\.[XxRrMmDdTt][TtMmDdSsNnEe][PpAaMmLlFfSsIi]?[EePp]*[Cc]*$" . xml-mode) auto-mode-alist))
>
> which has been working fine for years. It looks as if Emacs 23.2 defines
> xml-mode to point to nxml-mode, and this is somehow superseding my .emacs.
>
> Unfortunately I still need to use psgml's xml-mode for all my XML stuff.
> Does anyone know how I disable Emacs' new behaviour?
>
> ///Peter