Skip to content

Should argv clone the array? #8

Closed

Description

@no-longer-on-githu-b

Get an array containing the command line arguments. Be aware that this can change over the course of the program.

Does this mean the array itself may change? Because if that happens, then argv should return a clone of the array to keep users of the array referentially transparent.

Activity

  1. hdgarrood commented on Nov 27, 2016

    @hdgarrood
    Member

    Yes, the array itself can change, if you do something like process.argv.push('wat') in JS. I agree, cloning the array seems like the right thing to do. We might also consider exposing an API from this library that lets you mutate process.argv too.

  2. added
    purs-0.14A reminder to address this issue or merge this PR before we release PureScript v0.14.0
    on Dec 9, 2020
  3. thomashoneyman commented on Dec 9, 2020

    @thomashoneyman
    Contributor

    I think we should try and fix this for the upcoming 0.14 release for this library.

  4. jvliwanag commented on Dec 11, 2020

    @jvliwanag
    Contributor

    Perhaps we can simply set the type of argv as STArray Global String? This adds a dependency on st though.

  5. jvliwanag commented on Dec 11, 2020

    @jvliwanag
    Contributor

    Also, should we do the same for execArgv and env?

  6. hdgarrood commented on Dec 11, 2020

    @hdgarrood
    Member

    I think I’d prefer just providing a pair of Effect functions to get and set these values, eg argv :: Effect (Array String) and setArgv :: Array String -> Effect Unit

  7. jvliwanag commented on Dec 11, 2020

    @jvliwanag
    Contributor

    The neat think on the ST Global stuff is we can skip having to write custom ffi for freezing arrays and objects (for env). We can even delete the current ffi for setEnv and unsetEnv.

    We can always just hide the functions exposing ST Global if that's an issue. Or are we better off keeping it simple and dropping the ST Global entirely?

  8. hdgarrood commented on Dec 11, 2020

    @hdgarrood
    Member

    While it makes perfect sense to avoid FFI where possible in most contexts, I don’t think libraries whose purpose is to provide bindings to JS APIs is one of them. I think having custom FFI for these is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    purs-0.14A reminder to address this issue or merge this PR before we release PureScript v0.14.0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions