Code Monkey home page Code Monkey logo

Comments (3)

willghatch avatar willghatch commented on May 29, 2024

It doesn't work because foo is a runtime definition of a string, and the rash macro expects, at compile time, a syntax object that contains a string. So the "ls -l" string and the rash macro live at two different phases, and what the macro sees is a syntax object with the symbol foo inside.

I'm not sure what context you are trying to do this in, but there are various approaches you might take to do things that seem to be related.

If you are just trying to use different commands and arguments computed dynamically, you could use variables in the unix command, like this: (rash «$command (compute-args)») (Note that the arguments will splice if they are a list. $args should support splicing too, but I need to improve the dollar expansion to be more flexible -- right now it converts everything into a string, so you can't splice a list of arguments with it.)

If you want a whole pipeline segment to be computed dynamically (eg. to pass something like '(ls -l)), you could make an operator that just accepts the runtime pipeline-member objects. (This should by all means exist as one of the default available operators, I just haven't made it yet. I am also planning to add better support for using the DSL to create first-class pipeline segments, but I haven't yet decided what I want to do for certain edge cases. But it would be a really easy pipeline operator to make yourself if you want to try your hand at making one.) If you only want this for subprocess pipeline segments, you could also use (rash «(compute-everything)»), although that maybe wouldn't make a lot of sense unless it were part of a larger pipeline.

If you want to pass a string specifically instead of a list and have it be parsed as a command, eg. "ls -l" instead of '(ls -l), it would be easy to give this basic support by just splitting the string and passing it to the operator described above. But it wouldn't have support for anything fancy like dollar escapes without a little more elbow grease.

I guess for completeness I might say you could use eval, but that's probably a bad idea for most cases.

Does that help?

from racket-rash.

willghatch avatar willghatch commented on May 29, 2024

If you haven't been following Rash, the rash macro is no longer the recommended way to escape back into line-mode, but rather just using {} braces is recommended.

Should I close this issue, or is there anything else to address? Thanks.

from racket-rash.

pmatos avatar pmatos commented on May 29, 2024

@willghatch Haven't been following new developments but I gave it a try and it looks good. Thanks. Closing.

from racket-rash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.