arturo-lang / arturo

Simple, expressive & portable programming language for efficient scripting
http://arturo-lang.io
MIT License
700 stars 32 forks source link

[Paths/module] module isn't working properly for Windows OS #878

Closed RickBarretto closed 1 year ago

RickBarretto commented 1 year ago

Initially we are think that were an error from [Collections/split], as related on #872

More detailed what is happening here. (The problem isn't on this library itself), look:

I created a file called paths.art with this code: image

Look what happens when I run it:

image

So, look at lines 1750 and 1797. Arturo is using the function item.split(DirSep)), split is a nim's standard function from strutils.nim module, none problem here, and DirSep that also is a nim's standard function comes from osseps.nim module, none problem here too.

But, let's see what DirSep returns for windows systems:

  DirSep* =
    when defined(macos): ':'
    elif doslikeFileSystem or defined(vxworks): '\\'
    elif defined(RISCOS): '.'
    else: '/'
    ## The character used by the operating system to separate pathname
    ## components, for example: `'/'` for POSIX, `':'` for the classic
    ## Macintosh, and `'\\'` on Windows.

Yes, it'll split using a \. As Arturo's module function is returning with bot separators, it won't work. It'll separate just until user's path, and then a big string.

It's a issue related with module function.

Originally posted by @RickBarretto in https://github.com/arturo-lang/arturo/issues/872#issuecomment-1353092615

RickBarretto commented 1 year ago

I'm seeing how to solve it! 😉

RickBarretto commented 1 year ago

Alright, running on my local build: image

But, I got a question. Is this error at the end a bug? It's because I called from do again or what? Also, this behavior of h1 function is quite strange. LOOL

drkameleon commented 1 year ago

I just saw the issue you opened.

Just one notice: since module was supposed to work in a way that is really not valid anymore (the whole module/package system has not been used at all and is to be re-designed), I wouldn't really bother with module per se.

What I definitely would fix is how split.path works on Windows 😉

RickBarretto commented 1 year ago

Hummmmmm, got it! So, for windows, we add \\ and / support. I think it should be a good approach.

RickBarretto commented 1 year ago

Any way, I'll push because it's just one little change to fix it.