URLs in Ruby
ozmm.org
ozmm.org
EPEEN> #u"http://google.com"
#<URI http://google.com>
Thanks to the PURI library :-)The twitter example.
EPEEN> (let ((json (http-request #u"http://twitter.com/statuses/show/6592721580.json")))
(cdr (assoc :text (decode-json-from-string (octets-to-string json)))))
"He nose the truth."
Using puri, cl-json, drakma and babel.Perhaps there's a way to do it without any sort of syntax like the quotes or #u using macros?
You are complaining a Lisp URL needs to be quoted to distinguish it from other input tokens; how would you feel when you have more than one URL, say 10, on the screen and all of them are being echo'ed in a debug backtrace without visual aid or syntax highlighting? How about if you forget to delimit one with a space (oops, now you have a syntactically valid URL that's broken; the type checker wont help you verify URLs)
Plus you can "merge" Lisp URLs, forming absolute URLs from a base URL and appending paths to it or building query parameters in an elegant fashion.
However the original post/gist was just a bit of fun! So here is the same bit of fun in Perl: http://gist.github.com/256992
use Modern::Perl;
use Url;
use JSON qw(decode_json);
# output the json as is
say http://twitter.com/statuses/show/6592721580.json;
# => He nose the truth.
say decode_json( http://twitter.com/statuses/show/6592721580.json )->{text};
First time I've played with Devel::Declare module (http://search.cpan.org/dist/Devel-Declare/) and I found it to be straightforward & an extremely powerful beast for mangling with the perl5 parser in a robust and safe way.