Wikipedia maže svoje články?!

Oh, the humanity!

Zatiaľ čo sa národné wikipédie snažia násobiť svoj obsah, tá anglická v tichosti maže relevantné články. A tie praktiky. Nemám slov.

Súvisiace odkazy:

Emacs daemon

Ako daemon už niekoľko rokov používam aj prehrávač hudby (najskôr xmms2, potom mpd), takže som si už nejakú dobu takúto funkciu želal aj pre Emacs.

Emacs od verzie 23 má plne zabudovanú podporu spúšťania ako daemon a po niekoľkých mesiacoch musím skonštatovať, že som konečne spokojný. Skúšal som rôzne riešenia v predchádzajúcich verziách, ale nepodarilo sa mi to vyladiť k mojej spokojnosti.

Teraz stručne popíšem “setup”, ktorý mi vyhovuje. Používam 2 inštancie, jednu ako oddelený mailový klient (Wanderlust) a jednu na všetko ostatné (org-mode, LaTeX, programovanie, písanie textov). Príkazy, ktoré uvediem je možné si pomocou xbindkeys nastaviť na nejakú klávesovú skratku, nebudem uvádzať svoje, pretože to nie je podstatné.

Základom je spustenie daemona a klienta k nemu (klient je len nový frame, ktorý sa môže kedykoľvek zatvoriť a daemon to neovplyvní):

alias emacsd='emacs --daemon'
alias emacs='emacsclient -c'

Dôležité je aj vedieť daemona správne ukončiť, tieto aliasy ukončujú interaktívne a neinteraktívne (bezpodmienečné ukončenie bez uloženia zmien):

alias emacs-kill="emacsclient -e \"(progn (setq desktop-save \\\"~/\\\") (save-some-buffers) (kill-emacs))\""
alias emacs-kill-9="emacsclient -e \"(progn (setq desktop-save \\\"~/\\\") (save-some-buffers) (setq kill-emacs-hook 'nil) (kill-emacs))\""

Keď už máme stále bežiaci Emacs, tak na otvorenie súboru v ňom som si vytvoril funkciu aj so skráteným názvom eo:

emacs-open() { emacsclient -e "(find-file \"$1\")'" }
alias eo=emacs-open

Na záver som aplikoval nejaký vizuálny tuning, pretože štart Emacsu v textovom režime (platí aj pre daemon) nemôže nastaviť niektoré veci týkajúce sa len Gtk+ verzie:

emacsclient -c -e '(set-cursor-color "green")' -e '(load "~/.emacs.d/tabbar.el")' -e "(set-face-font 'tooltip \"DejaVu Sans 7\")"

A nakoniec ešte spustenie samostatného Emacsu s e-mailovým klientom, ktorý nepoužíva desktop (ukladanie zoznamu otvorených bufferov, histórie, atď.):

emacs -eval '(wl)' --no-desktop

Takéto oddelenie síce má svoje nevýhody, ale naopak ak potrebujem otvárať obrovské foldery až s desaťtisícami mailov, tak časom dokáže nabobtnať a je lepšie ho ukončiť a spustiť znovu.

Je mi smiešno z C++

Citujem z Trip Report: March 2010 ISO C++ Standards Meeting – Removed Export Template:

For context, the only reason we’re even considering this is because Edison Design Group (EDG), the only company to ever implement export, is recommending export be removed or deprecated. Recall that back in the 1990s the committee originally voted the feature in over EDG’s objections in the first place, then in the late 1990s and early 2000s EDG graciously and gallantly went on to invest enormous effort to implement the feature in order to conform to the standard, and so the committee was loath to punish them again by now removing the feature on them. However, given the passage of time, EDG reports that their experience in the field has been that nearly no one actually uses the feature, and that it would be right (and okay with EDG) to deprecate or remove it.

GCC a tail-call recursion

GCC so zapnutými optimalizáciami dokáže preložiť nasledujúci kód (ktorý nie je správne napísaná tail-call recursion) optimalizovane:

long fact(long x) {
    if (x <= 0)
        return 1;
 
    return x*fact(x-1);
}

Výsledok:

0000000000400494 <fact>:
  400494:	b8 01 00 00 00       	mov    $0x1,%eax
  400499:	48 85 ff             	test   %rdi,%rdi
  40049c:	7e 09                	jle    4004a7 <fact+0x13>
  40049e:	48 0f af c7          	imul   %rdi,%rax
  4004a2:	48 ff cf             	dec    %rdi
  4004a5:	eb f2                	jmp    400499 <fact+0x5>
  4004a7:	c3                   	retq   

Zdroj tohoto zázraku:

In addition to the standard tail recursion elimination, we handle the most trivial cases of making the call tail recursive by creating accumulators. For example the following function
int sum (int n)
{
  if (n > 0)
    return n + sum (n - 1);
  else
    return 0;
}


is transformed into

int sum (int n)
{
  int acc = 0;
 
  while (n > 0)
    acc += n--;
 
  return acc;
}

(http://gcc.gnu.org/viewcvs/trunk/gcc/tree-tailcall.c?revision=151935&view=markup)

Ukážka vývoja DSL v Lispe

V súvislosti s posledným zápisom som našiel ukážkové video vývoja DSL v Common Lispe, pre záujemcov to budem nejaký čas seedovať (125 MiB, 19 min.):

dsl_domain_specific_language_in_lisp.3735468.tpb.torrent

dsl-in-lisp-small.jpg

weblog.txt · Last modified: 2010/08/03 06:21 by 127.0.0.1