You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
Build Your Own Lisp Learn C and build your own programming language in 1000 lines of code! If you're looking to learn C, or you've ever wondered how to build your own programming language, this is the book for you. In just a few lines of code, I'll teach you how to use C, and together, we'll start building your very own language. Along the way we'll learn about the weird and wonderful nature of Li
I have two macros FOO2 and FOO3: #define FOO2(x,y) ... #define FOO3(x,y,z) ... I want to define a new macro FOO as follows: #define FOO(x,y) FOO2(x,y) #define FOO(x,y,z) FOO3(x,y,z) But this doesn't work because macros do not overload on number of arguments. Without modifying FOO2 and FOO3, is there some way to define a macro FOO (using __VA_ARGS__ or otherwise) to get the same effect of dispatchi
2009/09/07 毎年夏に開催される軽量プログラミング言語(LL:Lightweight Language)をテーマにした「LLイベント」。第7回目となる「LLTV」が、2009年8月29日に東京・中野で開催された。この記事ではプログラムの一部、「大改善!!劇的ビフォーアフター」をレポートする。前編では、Rubyによるfortuneコマンドの“増築”と、Firefox拡張によるslコマンドの実装というネタ系発表をレポートした。中編となる本記事では、C言語にLisp風のマクロを取り入れ、lsコマンドのソースコードを約半分に“修繕”する匠の技をレポートする。後編では、売り場業務が滞りがちだった販売管理システムをbashコマンドで“建て直した”という劇的ビフォーアフターの発表をレポートする。 Cで書かれたlsのソースコードの問題点 「Real/Macro Metaprogramming On
誰もが知ってるls(1)コマンド ソースはFreeBSDから (simple, no-dependency) 素直で読みやすいコード C言語ソースとしては優等 しかし… 問題点1 - 冗長なコード cmp.c int namecmp(const FTSENT *a, const FTSENT *b) { return (strcoll(a->fts_name, b->fts_name)); } int revnamecmp(const FTSENT *a, const FTSENT *b) { return (strcoll(b->fts_name, a->fts_name)); } 問題点1 - 冗長なコード (cont'd) util.c 同じ構造の4つの関数 while ((clen = mbrtowc(&wc, ...)) != 0) { if (clen == (size_t)-
こりゃ出番だ!...と思ったとか、思わなかったとか... ()()で呼び出せるJavaScriptのネスト関数の活用法を思いついた - あと味 ()()で呼び出すネスト関数の活用方法を考えたのですが、考えて出した答えがこれです。 http://d.hatena.ne.jp/jdg/20091020/1256042918 関数ポインタとか、operator()でもいいんだけど、リテラルを使いたくなかったのでマクロで... #include <stdio.h> #include <stdlib.h> #include <string.h> #define eq(x,y) !strcmp(x,y) #define X(x) oppai(#x); #define _(x) oppai(#x); X void oppai(const char* rhs) { static const char* l
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く