<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">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:<div><br></div><div>(stuff 'COMPANY)</div><div><br></div><div>rather than</div><div><br></div><div>(hash-ref stuff 'COMPANY)</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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:</div><div><br></div><div>; current STYLE #1</div><div>(define (current-rpc-receiver data)</div><div> (define company (hash-ref data 'COMPANY #f))</div><div> (when company</div><div> (db-exec … company))</div><div><br></div><div>; current STYLE #2</div><div>(define (curt-style-rpc-receiver data)</div><div> (define HF (hash->procedure data))</div><div> (when (HF 'COMPANY)</div><div> (db-exec …. (HF 'COMPANY))</div><div><br></div><div>; what would be handier….</div><div><br></div><div>(define (handy-style data)</div><div> (when (data 'COMPANY)</div><div> (db-exec … (data 'COMPANY))</div><div><br></div><div>Thanks in advance for any advice leading to more succinct hash access.</div><div><br></div><div><div><div><div apple-content-edited="true">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>------</div><div>John Griffin, CTO</div><div>IT Talent Team, LLC</div><div><a href="http://www.ittalentteam.com">www.ittalentteam.com</a></div><div>855-488-8326</div><div><br></div><div><br></div></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>
<br></div></div></div></body></html>