From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.lisp.guile.user Subject: Re: Guile base64 Date: Tue, 28 Sep 2010 14:48:36 +0200 Message-ID: <87tylayqxn.fsf@ambire.localdomain> References: <1283364621.2401.8.camel@romel-compaq> <87fwxsftsu.fsf@gnu.org> <871v9blnyr.fsf@delenn.lan> <1283544958.4017.4.camel@romel-compaq> <87zkvvsvif.fsf@ambire.localdomain> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1285678429 26262 80.91.229.12 (28 Sep 2010 12:53:49 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 28 Sep 2010 12:53:49 +0000 (UTC) Cc: guile-user@gnu.org To: Andy Wingo Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Sep 28 14:53:48 2010 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P0Zgd-0005B9-2w for guile-user@m.gmane.org; Tue, 28 Sep 2010 14:53:47 +0200 Original-Received: from localhost ([127.0.0.1]:59393 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0Zga-00075A-VE for guile-user@m.gmane.org; Tue, 28 Sep 2010 08:53:33 -0400 Original-Received: from [140.186.70.92] (port=48085 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0ZgK-000752-V7 for guile-user@gnu.org; Tue, 28 Sep 2010 08:53:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P0ZgJ-0001IT-Hb for guile-user@gnu.org; Tue, 28 Sep 2010 08:53:16 -0400 Original-Received: from smtp205.alice.it ([82.57.200.101]:39760) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0ZgJ-0001Hw-3j for guile-user@gnu.org; Tue, 28 Sep 2010 08:53:15 -0400 Original-Received: from ambire.localdomain (95.244.64.183) by smtp205.alice.it (8.5.124.08) id 4C1A2645066B9A28; Tue, 28 Sep 2010 14:52:27 +0200 Original-Received: from ttn by ambire.localdomain with local (Exim 4.69) (envelope-from ) id 1P0Zbo-0005p4-Dv; Tue, 28 Sep 2010 14:48:36 +0200 In-Reply-To: (Andy Wingo's message of "Mon, 06 Sep 2010 11:59:15 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Windows 98 (1) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8191 Archived-At: --=-=-= () Andy Wingo () Mon, 06 Sep 2010 11:59:15 +0200 Perhaps we could combine interfaces -- the stream-based (I presume; I haven't seen your code yet, but I know your Scheme code looks good) interfaces from yours, and the map-3-to-4 stuff from Andreas' R6RS port of my base64.scm. I say this because the r6rs port already uses bytevectors, and compiles down to fairly tight VM code. I haven't run benchmarks though. Please find below a five-minute port of (ice-9 base64) to Guile 1.9.x. To play, write it to /tmp and try something like: $ cd /tmp $ cat > hack < A $ guile -l base64.scm -s hack | diff A - Probably the next step is to settle the interface. I am biased towards 1.4.x compatability but am open (albeit reluctantly) to breaking it. Once the interface is settled, i'll add docs and some perfunctory tests and repost. WRT performance -- feel free to rewrite things afterwards; i'm not yet up to speed (har har) on this area of Guile development enough to help more than hinder. --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=base64.scm Content-Transfer-Encoding: base64 Ozs7IGJhc2U2NC5zY20gLS0tIGJhc2U2NCBlbmNvZGUvZGVjb2RlCgo7OyBDb3B5c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HV0KQogICAgICAgICAoY29ucyAoZ2V0YiEtcHJv YyAob3Blbi1pbnB1dC1zdHJpbmcgaW5wdXQpKQogICAgICAgICAgICAgICAoc3RyaW5nLWxlbmd0 aCBpbnB1dCkpKQogICAgICAgICgocG9ydD8gaW5wdXQpCiAgICAgICAgIChjb25zIChnZXRiIS1w cm9jIGlucHV0KQogICAgICAgICAgICAgICAoYW5kIChwb3J0LWZpbGVuYW1lIGlucHV0KQogICAg ICAgICAgICAgICAgICAgIChsZXQgKChndWVzcyAoZmFsc2UtaWYtZXhjZXB0aW9uCiAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAoc3RhdDpzaXplIChzdGF0IGlucHV0KSkpKSkKICAg ICAgICAgICAgICAgICAgICAgIChhbmQgKG51bWJlcj8gZ3Vlc3MpCiAgICAgICAgICAgICAgICAg ICAgICAgICAgIChwb3NpdGl2ZT8gZ3Vlc3MpCiAgICAgICAgICAgICAgICAgICAgICAgICAgIGd1 ZXNzKSkpKSkKICAgICAgICAoZWxzZSAjZikpKQoKKGRlZmluZSBjMmkgY2hhci0+aW50ZWdlcikK KGRlZmluZSBpMmMgaW50ZWdlci0+Y2hhcikKCihkZWZpbmUgKGNoYXIrIGMgbikKICAoaTJjICgr IChjMmkgYykgbikpKQoKKGRlZmluZSAqcmVhc29uYWJsZS1jaHVuayogKGFzaCAxIChhc2ggMSAo YXNoIDEgKGFzaCAxIChhc2ggMSAwKSkpKSkpIDsgNjQgS2lCCgooZGVmaW5lIHN1YnMgc3Vic3Ry aW5nKQoKKGRlZmluZSAobWFrZS1idWZmZXItc3RhY2sgc2l6ZSkKICAobGV0ICgoY3VyICNmKSAo c3RhY2sgJygpKSAoaWR4IHNpemUpKQoKICAgIChkZWZpbmUgKG5ldyEpCiAgICAgIChzZXQhIGN1 ciAobWFrZS1zdHJpbmcgc2l6ZSkpCiAgICAgIChzZXQhIHN0YWNrIChjb25zIGN1ciBzdGFjaykp CiAgICAgIChzZXQhIGlkeCAwKSkKCiAgICAoZGVmaW5lIChzcGlsbCEpCiAgICAgIChvciAoPSBp ZHggc2l6ZSkgKHNldC1jYXIhIHN0YWNrIChzdWJzIChjYXIgc3RhY2spIDAgaWR4KSkpCiAgICAg IChsZXQgKChyZXMgKGFwcGx5IHN0cmluZy1hcHBlbmQgKHJldmVyc2UhIHN0YWNrKSkpKQogICAg ICAgIChzZXQhIGN1ciAjZikKICAgICAgICAoc2V0ISBzdGFjayAnKCkpCiAgICAgICAgKHNldCEg aWR4IHNpemUpCiAgICAgICAgcmVzKSkKCiAgICA7OyBydgogICAgKGxhbWJkYSAoYykKICAgICAg KGNvbmQgKGMgKGFuZCAoPSBpZHggc2l6ZSkgKG5ldyEpKQogICAgICAgICAgICAgICAoc3RyaW5n LXNldCEgY3VyIGlkeCBjKQogICAgICAgICAgICAgICAoc2V0ISBpZHggKDErIGlkeCkpKQogICAg ICAgICAgICAoZWxzZSAoc3BpbGwhKSkpKSkpCgooZGVmaW5lIChtYWtlLW91dHAtYnVmZmVyIG91 dHAgc2l6ZSkKICAobGV0ICgoYnVmIChtYWtlLXN0cmluZyBzaXplKSkgKGlkeCAwKSAoY291bnQg MCkpCgogICAgKGRlZmluZSAoPk9VVCBmbHVzaD8geCkgICAgOzs7IHRvZG86IG1ha2Ugbm9uLWJs b2NraW5nIGlmIChub3QgZmx1c2g/KQogICAgICAoZGlzcGxheSB4IG91dHApCiAgICAgIChhbmQg Zmx1c2g/IChmb3JjZS1vdXRwdXQgb3V0cCkpKQoKICAgIChkZWZpbmUgKG5ldyEpCiAgICAgICg+ T1VUICNmIGJ1ZikKICAgICAgKHNldCEgaWR4IDApKQoKICAgIChkZWZpbmUgKHNwaWxsISkKICAg ICAgKD5PVVQgI3QgKGlmICg9IGlkeCBzaXplKSBidWYgKHN1YnMgYnVmIDAgaWR4KSkpCiAgICAg IChzZXQhIGlkeCAwKQogICAgICAobGV0ICgocnYgY291bnQpKQogICAgICAgIChzZXQhIGNvdW50 IDApCiAgICAgICAgcnYpKQoKICAgIDs7IHJ2CiAgICAobGFtYmRhIChjKQogICAgICAoY29uZCAo YyAoYW5kICg9IGlkeCBzaXplKSAobmV3ISkpCiAgICAgICAgICAgICAgIChzdHJpbmctc2V0ISBi dWYgaWR4IGMpCiAgICAgICAgICAgICAgIChzZXQhIGlkeCAoMSsgaWR4KSkKICAgICAgICAgICAg ICAgKHNldCEgY291bnQgKDErIGNvdW50KSkpCiAgICAgICAgICAgIChlbHNlIChzcGlsbCEpKSkp KSkKCihkZWZpbmUgKG1ha2Utb2IhIG91dHB1dCBzaXplKSAgICAgICAgICA7IG91dHB1dCBidWZm ZXJlcgogIChpZiBvdXRwdXQKICAgICAgKG1ha2Utb3V0cC1idWZmZXIgKGlmIChlcT8gI3Qgb3V0 cHV0KQogICAgICAgICAgICAgICAgICAgICAgICAgICAgKGN1cnJlbnQtb3V0cHV0LXBvcnQpCiAg ICAgICAgICAgICAgICAgICAgICAgICAgICBvdXRwdXQpCiAgICAgICAgICAgICAgICAgICAgICAg IChtaW4gKnJlYXNvbmFibGUtY2h1bmsqIHNpemUpKQogICAgICAobWFrZS1idWZmZXItc3RhY2sg c2l6ZSkpKQoKOzs7IGVuY29kaW5nCgooZGVmaW5lICplbmMtbWFwKgogIChsZXQgKChlbSAobWFr ZS12ZWN0b3IgNjQgI2YpKSkKICAgICh2ZWN0b3Itc2V0ISBlbSA2MiAjXCspCiAgICAodmVjdG9y LXNldCEgZW0gNjMgI1wvKQogICAgKGRvICgoaSAwICgxKyBpKSkpCiAgICAgICAgKCg9IGkgMjYp IGVtKSAgICAgICAgICAgICAgICAgICA7IHJ2CiAgICAgIChhbmQgKDwgaSAxMCkKICAgICAgICAg ICAodmVjdG9yLXNldCEgZW0gKCsgNTIgaSkgKGNoYXIrICNcMCBpKSkpCiAgICAgICh2ZWN0b3It c2V0ISBlbSAoKyAwIGkpIChjaGFyKyAjXEEgaSkpCiAgICAgICh2ZWN0b3Itc2V0ISBlbSAoKyAy NiBpKSAoY2hhcisgI1xhIGkpKSkpKQoKKGRlZmluZSAoZW5jb2RlISBvdXRwdXQgZ2V0YiEgbGlu ZS1icmVhayBjcmxmIGV4cC1pbnB1dCkKICAobGV0KiAoKGJncnAgKGFuZCBsaW5lLWJyZWFrIChx dW90aWVudCAobWF4IDQgbGluZS1icmVhaykgNCkpKQogICAgICAgICAob2IhIChtYWtlLW9iISBv dXRwdXQKICAgICAgICAgICAgICAgICAgICAgICAgKGlmIGV4cC1pbnB1dAogICAgICAgICAgICAg ICAgICAgICAgICAgICAgOzsgY29tcHV0ZSBleGFjdCByZXN1bHQgc2l6ZQogICAgICAgICAgICAg ICAgICAgICAgICAgICAgKGxldCAoKHJhdyAoKiA0IChpbmV4YWN0LT5leGFjdAogICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoY2VpbGluZyAoLyAoMS0gZXhwLWlu cHV0KQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAzKSkpKSkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgrIHJhdyAoaWYgYmdy cAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgqIChxdW90aWVudCBy YXcgKCogNCBiZ3JwKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAoaWYgY3JsZiAyIDEpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IDApKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICpyZWFzb25hYmxlLWNodW5rKikpKQog ICAgICAgICAobGIhIChpZiBjcmxmCiAgICAgICAgICAgICAgICAgIChsYW1iZGEgKCkgKG9iISAj XGNyKSAob2IhICNcbmV3bGluZSkpCiAgICAgICAgICAgICAgICAgIChsYW1iZGEgKCkgICAgICAg ICAgICAob2IhICNcbmV3bGluZSkpKSkpCgogICAgKGRlZmluZSAoYWNjISB4KQogICAgICAob2Ih IChpZiB4ICh2ZWN0b3ItcmVmICplbmMtbWFwKiB4KSAjXD0pKSkKCiAgICAobGV0IGxvb3AgKChn cm91cCBiZ3JwKSkKICAgICAgKGxldCogKChnIChnZXRiISkpICAgICAgICAgICAgICAgIDsgZG8g bm90IHVzZSBgbGV0JyBoZXJlCiAgICAgICAgICAgICAobiAoZ2V0YiEpKQogICAgICAgICAgICAg KHUgKGdldGIhKSkpCiAgICAgICAgKGNvbmQgKGcKICAgICAgICAgICAgICAgKGFuZCBiZ3JwICh6 ZXJvPyBncm91cCkgKGJlZ2luIChsYiEpIChzZXQhIGdyb3VwIGJncnApKSkKICAgICAgICAgICAg ICAgKGFjYyEgKGFzaCBnIC0yKSkKICAgICAgICAgICAgICAgKGFjYyEgKGFuZCAob3IgZyBuKQog ICAgICAgICAgICAgICAgICAgICAgICAgIChsb2dpb3IgKGFzaCAobG9nYW5kIChvciBnIDApIDMp IDQpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAobG9nYW5kIChhc2ggKG9yIG4g MCkgLTQpIDE1KSkpKQogICAgICAgICAgICAgICAoYWNjISAoYW5kIChvciBuIHUpCiAgICAgICAg ICAgICAgICAgICAgICAgICAgKGxvZ2lvciAoYXNoIChsb2dhbmQgKG9yIG4gMCkgMTUpIDIpCiAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoYXNoIChvciB1IDApIC02KSkpKQogICAg ICAgICAgICAgICAoYWNjISAoYW5kIHUgKGxvZ2FuZCB1IDYzKSkpKSkKICAgICAgICAoaWYgKGFu ZCBnIG4gdSkKICAgICAgICAgICAgKGxvb3AgKGFuZCBiZ3JwICgxLSBncm91cCkpKQogICAgICAg ICAgICAob2IhICNmKSkpKSkpCgo7OyBXcml0ZSB0byBAdmFye291dC1wb3J0fSB0aGUgcmVzdWx0 IG9mIGJhc2U2NC1lbmNvZGluZyBAdmFye2lucHV0fSBhbmQKOzsgcmV0dXJuIHRoZSBudW1iZXIg b2YgYnl0ZXMgd3JpdHRlbi4gIElmIEB2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iAgICAgICAgICAgICAgICAgICAgICAgIChj YXIgcGFpcikKICAgICAgICAgICAgICAgICAgICAgICAgKGFuZCAobm90IChudWxsPyBvcHRzKSkK ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoY2FyIG9wdHMpKQogICAgICAgICAgICAgICAg ICAgICAgICAoYW5kIChub3QgKG51bGw/IG9wdHMpKQogICAgICAgICAgICAgICAgICAgICAgICAg ICAgIChub3QgKG51bGw/IChjZHIgb3B0cykpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAg IChjYWRyIG9wdHMpKQogICAgICAgICAgICAgICAgICAgICAgICAoY2RyIHBhaXIpKSkpCiAgICAg IChlcnJvciAiYmFkIGlucHV0OiIgaW5wdXQpKSkKCjs7OyBkZWNvZGluZwoKKGRlZmluZSAqZGVj LW1hcCoKICAobGV0ICgoZG0gKG1ha2UtdmVjdG9yIDI1NiAjZikpKQogICAgKGRvICgoaSAwICgx KyBpKSkpCiAgICAgICAgKCg9IGkgNjQpIGRtKSAgICAgICAgICAgICAgICAgICA7IHJ2CiAgICAg ICh2ZWN0b3Itc2V0ISBkbSAoYzJpICh2ZWN0b3ItcmVmICplbmMtbWFwKiBpKSkgaSkpKSkKCihk ZWZpbmUgYnl0ZS13aGl0ZXNwYWNlPwogIChsZXQgKCh3cy1ieXRlcyAobWFwIGMyaSAnKCNcc3Bh Y2UgI1xucCAjXG5sICNcY3IgI1xodCAjXHZ0KSkpKQogICAgKGxhbWJkYSAoYikgKG1lbXEgYiB3 cy1ieXRlcykpKSkKCihkZWZpbmUgKGRlY29kZSEgb3V0cHV0IGdldGIhIGV4cC1pbnB1dCkKICAo bGV0ICgob2IhIChtYWtlLW9iIQogICAgICAgICAgICAgIG91dHB1dAogICAgICAgICAgICAgIChp ZiBleHAtaW5wdXQKICAgICAgICAgICAgICAgICAgOzsgYXBwcm94aW1hdGUgcmVzdWx0IHNpemUg KHdoaXRlc3BhY2Ugbm90IGtub3duIGEgcHJpb3JpKQogICAgICAgICAgICAgICAgICAoaW5leGFj dC0+ZXhhY3QgKGNlaWxpbmcgKCogMyAoLyAoMSsgZXhwLWlucHV0KSA0KSkpKQogICAgICAgICAg ICAgICAgICAqcmVhc29uYWJsZS1jaHVuayopKSkpCgogICAgKGRlZmluZSAoYWNjISB4KQogICAg ICAob2IhIChpMmMgeCkpKQoKICAgIChkZWZpbmUgKGZpbmQhKQogICAgICAobGV0ICgoYiAoZ2V0 YiEpKSkKICAgICAgICAoYW5kIGIgKGlmIChieXRlLXdoaXRlc3BhY2U/IGIpCiAgICAgICAgICAg ICAgICAgICAoZmluZCEpCiAgICAgICAgICAgICAgICAgICAodmVjdG9yLXJlZiAqZGVjLW1hcCog YikpKSkpCgogICAgOzsgZG8gaXQhCiAgICAobGV0IGxvb3AgKCkKICAgICAgKGxldCogKChnIChm aW5kISkpICAgICAgICAgICAgICAgIDsgZG8gbm90IHVzZSBgbGV0JyBoZXJlCiAgICAgICAgICAg ICAociAoZmluZCEpKQogICAgICAgICAgICAgKG8gKGZpbmQhKSkKICAgICAgICAgICAgIChrIChm aW5kISkpKQogICAgICAgIChhbmQgZyByIChhY2MhIChsb2dpb3IgKGFzaCBnIDIpIChhc2ggciAt NCkpKSkKICAgICAgICAoYW5kIHIgbyAoYWNjISAobG9naW9yIChhc2ggKGxvZ2FuZCByIDE1KSA0 KSAoYXNoIG8gLTIpKSkpCiAgICAgICAgKGFuZCBvIGsgKGFjYyEgKGxvZ2lvciAoYXNoIChsb2dh bmQgbyAzKSA2KSBrKSkpCiAgICAgICAgKGlmIChhbmQgZyByIG8gaykKICAgICAgICAgICAgKGxv b3ApCiAgICAgICAgICAgIChvYiEgI2YpKSkpKSkKCjs7IFdyaXRlIHRvIEB2YXJ7b3V0LXBvcnR9 IHRoZSByZXN1bHQgb2YgYmFzZTY0LWRlY29kaW5nIEB2YXJ7aW5wdXR9IGFuZAo7OyByZXR1cm4g dGhlIG51bWJlciBvZiBieXRlcyB3cml0dGVuLiAgSWYgQHZhcntvdXQtcG9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