Code Monkey home page Code Monkey logo

Comments (12)

dieggsy avatar dieggsy commented on May 29, 2024

This might be a useful option - I stumbled into this when realizing exit didn't work, and I had to do (exit).

from racket-rash.

zlee-personal avatar zlee-personal commented on May 29, 2024

That's how I thought of it too. A kind of workaround you can do for exit is make a line macro called quit or something, I'm not sure if there's a way to name it exit due to circular deffinitions. You can also do |> exit, but that's not very easy to type.

from racket-rash.

willghatch avatar willghatch commented on May 29, 2024

So you can do this with a different pipeline operator, and you can set the default to be different ones. The way to set the top-level default in the repl is with a jenky set! command, but I hope to improve that at some point. In general it is a syntax parameter. Check out the =obj-if-def/unix-if-undef= operator in the shell-pipeline/demo/more-pipeline-operators.rkt file.

Perhaps something like that should be the default, but I'm somewhat hesitant to do that.

from racket-rash.

willghatch avatar willghatch commented on May 29, 2024

(I always use the C-d keystroke instead of (exit)...)

from racket-rash.

zlee-personal avatar zlee-personal commented on May 29, 2024

Stupid question, but how would I go about setting the top level as you mention? I tried:

(set! #%top =obj-if-def/unix-if-undef=)
; and
(set! default-pipeline-starter =obj-if-def/unix-if-undef=)

but it says bad syntax.

from racket-rash.

willghatch avatar willghatch commented on May 29, 2024

sigh Sorry I wasted your time with that -- somehow I thought it was documented, and I was sleepy. The form is (set-default-pipeline-starter! new-starter).

from racket-rash.

willghatch avatar willghatch commented on May 29, 2024

I have various thoughts about different ways I might do it going forward, but they are still a little nebulous and I put that one in just to have something available.

from racket-rash.

zlee-personal avatar zlee-personal commented on May 29, 2024

Something I noticed when using =obj-if-def/unix-if-undef= is that aliases are counted as identifiers, so it tries to run them using =object-pipe= which doesn't support macros as the first arg. Maybe something like =unix-if-supported/otherwise-racket= would be a good default, although I'm not sure how that would be implemented nicely, and not something like: try to run it with unix and if it fails, try to run it in racket.

from racket-rash.

zlee-personal avatar zlee-personal commented on May 29, 2024

I think it should prefer the executable over an identically named racket function, at least in the repl, since it's easier and more Intuitive to type (racket-function) that it is to type =unix-pipe= external-command

from racket-rash.

willghatch avatar willghatch commented on May 29, 2024

As I said about stuff in the demo directories -- half baked. But it wouldn't be too hard to get it to recognize aliases.

But the question of when to prefer what is one of the things keeping me from wanting it as a default. If you let any bound Racket identifier defer to =object-pipe= but you've imported something that happens to conflict with a command name that's annoying. But I think it would be even worse to check first if a program of the right name exists -- if you add a program to your path that happens to have the same name as a function you are using in a script, suddenly your script breaks.

from racket-rash.

willghatch avatar willghatch commented on May 29, 2024

That's also one of the reasons aliases exist (because frankly you could define aliases as pipeline operators instead) is to be able to define a set of Racket functions that you want to use without specifying a different pipeline operator without having the wonky behavior of an operator that checks if a program exists.

from racket-rash.

zlee-personal avatar zlee-personal commented on May 29, 2024

Yeah, the more I think about it, merging external programs and racket functions sounds like a bad idea. It's easy enough to make a line macro that can run racket functions.

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.