As to (@ data 'COMPANY), I've considered and used exactly that simply by (define @ hash-ref). And it's not bad because it's shorter. It's just not as good as (data 'COMPANY).
I do notice that the Clojure folks decided that dictionaries were functions such that (def talk { "cow" "moo" "dog" "bark" }) can be treated in function position. (talk "cow") I'll be looking at the #%app idea in a bit. ------ John Griffin, CTO IT Talent Team, LLC www.ittalentteam.com 855-488-8326 On Aug 5, 2013, at 12:00 PM, users-requ...@racket-lang.org wrote: > Send users mailing list submissions to > users@racket-lang.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > users-requ...@racket-lang.org > > You can reach the person managing the list at > users-ow...@racket-lang.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users] > > > Today's Topics: > > 1. Re: (procedure? (hash)) -> true (Tony Garnock-Jones) > 2. Re: (procedure? (hash)) -> true (Matthias Felleisen) > 3. issue with Dr Racket in linux platform. (Vikas Sood) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 05 Aug 2013 11:39:06 -0400 > From: Tony Garnock-Jones <to...@ccs.neu.edu> > To: John Griffin <j...@ittalentteam.com>, racket-users > <users@racket-lang.org> > Subject: Re: [racket] (procedure? (hash)) -> true > Message-ID: <51ffc71a.8080...@ccs.neu.edu> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > On 08/05/2013 11:30 AM, John Griffin wrote: >> Thanks in advance for any advice leading to more succinct hash access. > > Had you considered something along the lines of > > (define (handier-style data) > (when (@ data 'COMPANY) > (db-exec ... (@ data 'COMPANY)))) > > ? > > You might start from > > (define (@ base . path) > (match path > ['() base] > [(cons (? number? n) rest) > (apply @ (list-ref base n) rest)] > [(cons (? symbol? k) rest) > (apply @ (hash-ref base k) rest)] > [... maybe other things ...])) > > to give yourself a not-quite-XPath-like means of projecting JSON values. > > Interesting design decisions include: what to do when a list index is > out of range, or a hash key is not present? (Error? Terminate early > returning some kind of "undefined" value?) > > Cheers, > Tony > > > ------------------------------ > > Message: 2 > Date: Mon, 5 Aug 2013 11:52:49 -0400 > From: Matthias Felleisen <matth...@ccs.neu.edu> > To: John Griffin <j...@ittalentteam.com> > Cc: users@racket-lang.org > Subject: Re: [racket] (procedure? (hash)) -> true > Message-ID: <b4e00c63-e999-46a0-8478-9dc978698...@ccs.neu.edu> > Content-Type: text/plain; charset="windows-1252" > > > Consider overriding #%app for your modules. And > > (define (curt-style-receiver data) > (cond > [(data 'COMPANY) => (curry db-exec ...)] > [else .. what are you doing in the #f case? nothing? ...])) > > > On Aug 5, 2013, at 11:30 AM, John Griffin wrote: > >> I do a lot of work with hash as the result of JSON-RPC calls, with >> considerable use of hash-ref. In most places, I've replaced the hash with >> a local result of transforming the hash to a procedure so that I can: >> >> (stuff 'COMPANY) >> >> rather than >> >> (hash-ref stuff 'COMPANY) >> >> Of course, the setup call to exchange the hash for the procedure takes >> another line, such that I only bother on longer functions with repeated >> benefit. >> >> It certainly would be handy from a succinctness standpoint if a hash acted >> like a procedure (Any -> Any). Noticing that struct can be a procedure? via >> a property , I wonder if there's a way for hash? and procedure? to both hold >> true. >> >> It's more than simply saving the 9 letters of hash-ref followed by a space. >> Performance is not an issue and given a curt enough representation, I'd >> prefer calling it twice rather than making a local define. My current >> choices are: >> >> ; current STYLE #1 >> (define (current-rpc-receiver data) >> (define company (hash-ref data 'COMPANY #f)) >> (when company >> (db-exec ? company)) >> >> ; current STYLE #2 >> (define (curt-style-rpc-receiver data) >> (define HF (hash->procedure data)) >> (when (HF 'COMPANY) >> (db-exec ?. (HF 'COMPANY)) >> >> ; what would be handier?. >> >> (define (handy-style data) >> (when (data 'COMPANY) >> (db-exec ? (data 'COMPANY)) >> >> Thanks in advance for any advice leading to more succinct hash access. >> >> ------ >> John Griffin, CTO >> IT Talent Team, LLC >> www.ittalentteam.com >> 855-488-8326 >> >> >> >> >> >> >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > <http://lists.racket-lang.org/users/archive/attachments/20130805/2c2593f1/attachment-0001.html> > > ------------------------------ > > Message: 3 > Date: Mon, 5 Aug 2013 21:27:46 +0530 > From: Vikas Sood <vikaspr...@gmail.com> > To: users@racket-lang.org > Subject: [racket] issue with Dr Racket in linux platform. > Message-ID: > <capsg1m0ry3guqyagygcgmil8_d-h25jqbm0nhs8-9pjcehn...@mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > Hi > > When i am running any program in DR Racket following message is > being displayed. > > > #%module-begin: illegal use (not a module body) in: (#%module-begin). > > I am not able to run even the first sample code in racket in linux. > > I am not facing any problem while running the same code in windows. > > Kindly provide me with the cause and work around for linux. > > regards > > Vikas > > > End of users Digest, Vol 96, Issue 10 > *************************************
____________________ Racket Users list: http://lists.racket-lang.org/users