[plt-scheme] Is this possible with at-exp ?
On Jun 25, Jaime Vargas wrote:
> On Jun 25, 2009, at 3:38 PM, Eli Barzilay wrote:
>
> > On Jun 25, Jaime Vargas wrote:
> >> I would like to use the at-exp reader when coding system calls. Is
> >> there a form with similar behavior to @op[args] that transform every
> >> argument into a string?
> >>
> >> @system*[/usr/bin/ssh -o BatchMode=yes
> >> -o LogLevel=ERROR
> >> -o StrictHostKeyChecking=no
> >> -- @host @commands]
> >
> > I'm not sure what you're trying to achievem but if you're not using
> > text arguments, then there's no point in using the `at-exp' language.
>
> I am tying to avoid string-append and typing every string. I thing
> the above reads better than the alternatives:
>
> (system (string-append "/usr/bin/ssh -o BatchMode=yes -o
> LogLevel=ERROR -o StrictHostKeyChecking=no -- " host " " commands))
Well, doing this is simple; you'll need something like:
(define sys (compose system string-append))
and then:
@sys{/usr/bin/ssh -o BatchMode=yes -o LogLevel=ERROR @;
-o StrictHostKeyChecking=no -- @host @commands}
> (system* "/usr/bin/ssh" "-o" "BacthMode=yes" "-o" "LogLevel=ERROR" "-
> o" "StrictHostKeyChecking=no" "--" host commands)
This would be trickier if you want to do it properly. A hackish
solution would be to split the string on spaces.
> I thought that maybe I could leverage `at-exp' language to accomplish
> this "special syntax." If `at-exp' doesn't help, how to implement
> this? Is it possible to extend `at-exp' to handle this case?
I don't know what extension you'd want to use there... If you want
separate strings, and if the strings don't suffer from things like
lots of double quotes and backslashes, then the usual string syntax is
fine.
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!