Git Product home page Git Product logo

inim's People

Contributors

0atman avatar andreiregiani avatar auxym avatar ehmry avatar jabbalaci avatar kaushalmodi avatar ninzine avatar ringabout avatar ryanc-signiq avatar tangdongle avatar timotheecour avatar yardanico avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

inim's Issues

option to handle errors by breaking into a debugger (same behavior as in ipython --pdb)

this feature is invaluable for debugging:

 ipython3 --pdb -i tests/python/t01_inim_issue_debug_on_error.py
Python 3.6.5 (default, Jun 20 2018, 01:40:23)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
~/git_clone/nim/timn/tests/python/t01_inim_issue_debug_on_error.py in <module>()
      4   print(b[3])
      5
----> 6 fun()

~/git_clone/nim/timn/tests/python/t01_inim_issue_debug_on_error.py in fun()
      2   a = 10
      3   b = [1, 2, 3]
----> 4   print(b[3])
      5
      6 fun()

IndexError: list index out of range
> /Users/timothee/git_clone/nim/timn/tests/python/t01_inim_issue_debug_on_error.py(4)fun()
      2   a = 10
      3   b = [1, 2, 3]
----> 4   print(b[3])
      5
      6 fun()

ipdb> h

Documented commands (type help <topic>):
========================================
EOF    cl         disable  interact  next    psource  rv         unt
a      clear      display  j         p       q        s          until
alias  commands   down     jump      pdef    quit     source     up
args   condition  enable   l         pdoc    r        step       w
b      cont       exit     list      pfile   restart  tbreak     whatis
break  continue   h        ll        pinfo   return   u          where
bt     d          help     longlist  pinfo2  retval   unalias
c      debug      ignore   n         pp      run      undisplay

Miscellaneous help topics:
==========================
exec  pdb

ipdb> whatis a
<class 'int'>
ipdb> pp a
10
ipdb> pp b
[1, 2, 3]

tests/python/t01_inim_issue_debug_on_error.py

def fun():
  a = 10
  b = [1, 2, 3]
  print(b[3])

fun()

implementation

this could actually be pretty simple:
we could use this when compiling programs:
nim --debugger:native|endb

NOTE: this option should be enabled / disabled during inim session

NOTE: more generally, options for nim compilation (cf the --nim= I added) should be customizable during inim session. Just need a good way to handle these "meta" commands

'which nim' error on Windows

Hi,

Installation via nimble goes smoothly, but when running on Windows 10, I get:

INim 0.1.0
Nim Compiler Version 0.18.0 [Windows: i386]
Error: unhandled exception: The system cannot find the file specified.

Additional info: Requested command not found: 'which nim'. OS error: [OSError]

Shouldn't it be 'where nim' on Windows?

Syntax highlighting

After each line, one can tokenize the code using nim scan, and colorize the input. It would be best if that happened after each char as in IPython, is it possible to have such a handler with linenoise?

Nimble package

This is an awesome project. Would be great to see it as a Nimble package :)

inim -s=mybug.nim crashes (should not crash, as done with `inim ; import mybug`)

bugs/t59_array_index.nim:

let a = @["a", "b", "c"]
echo a
echo a[^0]
  • inim -s=bugs/t59_array_index.nim should not crash
    BAD:
inim -s=bugs/t59_array_index.nim
inim_1531876765
/Users/timothee/git_clone/nim/Nim/lib/system.nim(3597) []
/Users/timothee/git_clone/nim/Nim/lib/system.nim(2807) sysFatal
Error: unhandled exception: index out of bounds [IndexError]
Error: execution of an external program failed: '/private/tmp/inim_1531876765 '

GOOD: doesn't crash, handles error gracefully when calling a crashing cmd

inim
INim 0.2.5
Nim Compiler Version 0.18.1 [MacOSX: amd64] at /Users/timothee/.nimble/bin/nim
>>> import bugs/t59_array_index
t59_array_index
/Users/timothee/git_clone/nim/Nim/lib/system.nim(3597) []
/Users/timothee/git_clone/nim/Nim/lib/system.nim(2807) sysFatal
Error: unhandled exception: index out of bounds [IndexError]
Error: execution of an external program failed: '/private/tmp/inim_1531876771 '
>>>

inim doesn't catch out of bound error

inim
INim 0.2.5
Nim Compiler Version 0.18.1 [MacOSX: amd64] at /Users/timothee/.nimble/bin/nim
>>> import sequtils, os
>>> echo toSeq(parentDirs("/a/b"))
@["/a/b", "/a", ""]
>>> let a=toSeq(parentDirs("/a/b"))
>>> a
@["/a/b", "/a", ""] : seq[string]
>>> a[0]
/a/b : string
>>> a[1]
/a : string
>>> a[-1]
@["/a/b", "/a", ""]
>>>

the last entry is shown in red (as is the case for errors), but should show the error instead of returning non-sensical @["/a/b", "/a", ""]

lots of inim_xxxx.exe files created on Windows!

On Windows the inim_xxxx.exe file and the nimcache directory do not get cleaned up after exiting the interpreter. Also, if you quit break from the interpreter with Ctrl+C, the inim_xxxx.nim file does not get deleted.
Example: If I run inim.exe 5 times, then 5 inim_xxxx.exe files get created in the current working directory.

Autocompletion

Based on TAB, linenoise should have this functionality, one should be able to somehow call nimsuggest , but for the first implementation, just a set with all the defined names in the active session should be fine.

If that seems useful, I can implement it

support one liners with `#? braces` syntax

1 liners are very useful for REPL, otherwise cmd recall is kind of broken.

braces syntax allow arbitrary nim code to fit in 1 line.

eg:
>>> proc fun(a:int): auto {return a*2}

implementation:
using undocumented(?) ``#? braces` syntax

eg:
foo.nim

#? braces

proc main() {
  echo "Hello"
}

when (isMainModule) {
  main()
}

this mode could be enabled via a meta option, see #6, eg :brace=on or :brace=off

`inim -i -s=file` to enter interactive inim session instead of exiting upon completion

ipython3 --help:

If you  specify the option `-i` before the filename, it will enter an interactive
    IPython session after running the script, rather than exiting. Files ending
    in .py will be treated as normal Python, but files ending in .ipy can
    contain special IPython syntax (magic commands, shell expansions, etc.).

as ipython, inim should not exit inim shell upon completion of the script file, regardless of success/failure

  • NOTE: the .ipy point is interesting, we could have a .inim with same intent; would be useful eg for testing inim; that point is low priority though

[SPEED] investigate options for improving compilation time in inim

  • if there is not adverse consequence on error messages (eg if we never need to look at bufferSource), would it make sense to get the source from from stdin instead of dumping to a temp file bufferSource ? nim can read from stdin using -

  • curious also whether compiler/nimeval could speed things up (calling compiler as a library instead of shelling out)

  • just posted https://forum.nim-lang.org/t/4048 : "how to get detailed compilation timing statistics (time spent in each phase, nim=>C=>.o=>binary) ? " to see whether we can measure bottlenecks in compile time speed

INimrc file?

Perhaps we could load user config for the app itself from a dotfile or a config file, allowing users to switch on/off features and change certain config.

a "help" command would be useful

A "help" command in the REPL would be useful. When I tried INim, I could only guess how to quit. Ctrl+D didn't work (I just sent a PR about it), "help" wasn't available.

Update: I can do it in the form of a PR.

Request for executable (at least for Windows)

CAN I HAZ A BINARY PLZ
,,,^. .^,,,
Reason — to provide a better "playground" experience for Nim. INim is closer to hardware than online in-browser interpreters and therefore has the potential to be much faster.
But without an easily accessible binary executable people with urge to immediately try Nim are losing this kind of opportunity. Self-contained portable package would be awesome to have. :)
Thank you!

Broken on devel

$ nimble install inim
Downloading https://github.com/AndreiRegiani/INim using git
  Verifying dependencies for inim@0.4.1
      Info: Dependency on cligen@>= 0.9.15 already satisfied
  Verifying dependencies for cligen@0.9.15
 Installing inim@0.4.1
   Building inim/inim using c backend
    Prompt: Build failed for '[email protected]', would you like to try installing 'inim@#head' (latest unstable)? [y/N]
    Answer: y
Downloading https://github.com/AndreiRegiani/INim using git
  Verifying dependencies for inim@#head
      Info: Dependency on cligen@>= 0.9.15 already satisfied
  Verifying dependencies for cligen@0.9.15
 Installing inim@#head
   Building inim/inim using c backend
       Tip: 13 messages have been suppressed, use --verbose to show them.
     Error: nimble.nim(1106)         nimble
        ... nimble.nim(1044)         doAction
        ... nimble.nim(497)          install
        ... nimble.nim(483)          install
        ... nimble.nim(359)          installFromDir
        ... nimble.nim(253)          buildFromDir
        ... nimble.nim(245)          buildFromDir
        ... Build failed for package: inim
        ... Details:
        ... nimble.nim(1106)         nimble
        ... nimble.nim(1044)         doAction
        ... nimble.nim(497)          install
        ... nimble.nim(483)          install
        ... nimble.nim(359)          installFromDir
        ... nimble.nim(253)          buildFromDir
        ... nimble.nim(237)          buildFromDir
        ... tools.nim(37)            doCmd
        ... Execution failed with exit code 1
        ... Command: "/home/juan/.nimble/bin/nim" c --noBabelPath -d:release --path:"/home/juan/.nimble/pkgs/cligen-0.9.15"  -o:"/tmp/nimble_7403/githubcom_AndreiRegianiINim_#head/inim" "/tmp/nimble_7403/githubcom_AndreiRegianiINim_#head/src/inim.nim"
        ... Output: Hint: used config file '/home/juan/.choosenim/toolchains/nim-#devel/config/nim.cfg' [Conf]
        ... Hint: system [Processing]
        ... Hint: inim [Processing]
        ... Hint: os [Processing]
        ... Hint: strutils [Processing]
        ... Hint: parseutils [Processing]
        ... Hint: math [Processing]
        ... Hint: bitops [Processing]
        ... Hint: algorithm [Processing]
        ... Hint: unicode [Processing]
        ... Hint: times [Processing]
        ... Hint: options [Processing]
        ... Hint: typetraits [Processing]
        ... Hint: strformat [Processing]
        ... Hint: macros [Processing]
        ... Hint: posix [Processing]
        ... Hint: ospaths [Processing]
        ... Hint: osproc [Processing]
        ... Hint: strtabs [Processing]
        ... Hint: hashes [Processing]
        ... Hint: streams [Processing]
        ... Hint: cpuinfo [Processing]
        ... Hint: linux [Processing]
        ... Hint: rdstdin [Processing]
        ... Hint: linenoise [Processing]
        ... Hint: termios [Processing]
        ... Hint: terminal [Processing]
        ... Hint: colors [Processing]
        ... Hint: tables [Processing]
        ... inim.nim(79, 16) Error: type mismatch: got <nil> but expected 'string'

$ choosenim --version
choosenim v0.3.2 (2018-02-28 14:12:37) [linux/amd64]

$ choosenim show
   Channel: devel
   Version: #devel
      Path: /home/juan/.choosenim/toolchains/nim-#devel

$ uname -a
Linux z 4.18.7-arch1-1-ARCH #1 SMP PREEMPT Sun Sep 9 11:27:58 UTC 2018 x86_64 GNU/Linux

$ nim --version
Nim Compiler Version 0.18.1 [Linux: amd64]
Compiled at 2018-09-14
Copyright (c) 2006-2018 by Andreas Rumpf

active boot switches: -d:release

support meta commands (eg to manipulate history etc)

https://github.com/wheineman/nrpl allows using meta commands, eg:

> :help
:? - print this help
:help - print this help
:history - display history
:clearHist - clear history
:delete n[,m] - delete line or range of lines from history
:load filename - clears history and loads a file into history
:append filename - appends a file into history
:save filename - saves history to file
:run - run what's currently in history
:version - display the current version
:quit - exit REPL
:remove varname - remove variable

this would be quite useful, eg also for enabling #5 via, say, :brace=on or :brace=off

can these be implemented as regular procs?

(and inim would automatically call from inim_special_commands as z import nil)
eg:

z.help()
z.history()
#etc

Edit command using external editor

On shells it's usually available a way to edit the command on a external editor. For instance in Bash it's <ctrl>+x e, on Fish it's <esc> e. This launches the default text editor at the $EDITOR env var (usually vim or nano) to edit the current command prompt.

It's a very useful feature when you have to edit multiline snippets from history or just want to copy-paste something without the ... prompt.

Great project!

[feature] `inim -s:foo.nim -- args...` => passes args to script foo.nim

proposal

inim -s:foo.nim -- arg1 arg2 # passes arguments arg1, arg2 to script foo.nim (eg see [1])
cat foo.nim | inim -- arg1 arg2
inim -- arg1 arg2 # now typing `echo paramStr(1)` on inim prompt would print `arg1`

The -- is needed

it avoids unnecessary ambiguities (and makes it easy to parse visually which is an argument to inim, which is an argument to the script)
eg: with -- required:

inim -s:foo.nim -- -h # -h passed to foo
inim -s:foo.nim -h -- # -h passed to inim; same as: `inim -s:foo.nim -h`
cat foo.nim | inim -- -s:bar.nim # -s:bar.nim bassed to foo (contrived example...)

if -- were not required:

inim -s:foo.nim -h # ambiguous: is -h a inim argument or an argument for foo? this ambiguity affects programs like grep which add a `-e` to disambiguate when patterns begin with `-`
cat foo.nim | inim -s:bar.nim # ambiguous

here's how other programs handle passing arguments:

  • programs that read interactively from stdin (such as inim):
ipython ipython_args... -- args... # this is same as my suggestion
lldb lldb_args... -- foo args... # similar, because -- is used as delimiter
gdb gdb_args... --args foo args... # similar, because --args is used as delimiter
  • programs that don't read interactively from stdin:
nim nim_arg(with -r)... foo.nim args... # note, nim doesn't interactively read from stdin (unless `-` is passed IIRC?), so not having `--` is less of an issue for it
dmd dmd_args...  -run foo.d args... 

(dmd's case is bad, see dlang/dmd#7927)

[1] example for foo.nim:
bugs/inim/t03_cmdline.nim:

import os
for i in 1..paramCount():
  echo (i, paramStr(i))

print values without using "echo"

Coming from Python, I really like that you can do this:

>>> a = 7
>>> a
7
>>> 1+1
2

That is, when you create a variable, you can print its value without using the print() function. The same is true for expressions.

INim works like this at the moment:

nim> var a = 7
nim> a
Error: expression 'a' is of type 'int' and has to be discarded; start of expression here: inim_1539330313.nim(1, 0)
nim> 1+1
Error: expression '2' is of type 'int literal(2)' and has to be discarded; start of expression here: inim_1539330313.nim(1, 0)
nim>

It would be great if we could mimic the Python REPL. Maybe it could be done like this: try to execute the line as it is. If there is an error, rewrite the line by adding "echo" to the beginning of the line and re-execute the line. The second time output everything.

Or, a less appealing solution could be to define an alias function called "e" for instance that points on "echo". Thus we could print easier:

>>> var a = 7
>>> e a    # short for `echo a`
7
>>>

How to Install INim?

I have

nim -v
Nim Compiler Version 0.18.0 [Linux: amd64]

I was trying to install inim

nimble install inim --verbose
Reading official package list
Downloading https://github.com/AndreiRegiani/INim using git
Cloning latest tagged version: 0.2.5
Setting Nim stdlib prefix to /home/appu/Nim
Setting Nim stdlib path to /home/appu/Nim/lib
Verifying dependencies for [email protected]
Error: Couldn't find Nim version.

I tried

which nim
/home/appu/.nimble/bin/nim

and

whereis nim
nim: /usr/lib/nim /etc/nim.cfg /usr/share/nim /home/appu/bin/nim /home/appu/.nimble/bin/nim /home/appu/Nim/bin/nim

What should I do?

[minor] syntax highlight using nimsuggest

  • maybe the 1st easy step would be to colorize the prompt; making it easy to distinguish cmds from outputs
  • the errors/warnings produced by nim can be kept with their color (probably a way to force color output even if not a tty?)
  • nimsuggest cor colorizing commands

Allow symbol definition on inim startup ie -d:ssl

I'm currently writing some code that needs SSL support, done by compiling with the -d:ssl switch. It doesn't seem inim has support for passing custom switches to the compiler though, so my code doesn't work with inim.

It'd be great to allow arbitrary parameters to be passed to the compiler.

Windows IOError

Hi,

Installed the latest INim with today's devel version of Nim x64 on Windows 10 x64 and get the following error when executing inim.exe:

Error: unhandled exception: Unknown IO Error [IOError]

Any ideas?

[RFC] Give unique prompt symbol (>>>) to Nim

Whether to keep >>> or come up with something unique for Nim? The issue was raised in the Telegram group, causing confusion when comparing Python and Nim code, copying & pasting from REPL.

Suggested:

  • Nim>
  • nim>
  • nim =}>

Echo char

INim 0.2.4
Nim Compiler Version 0.18.1 [Linux: amd64] at /usr/bin/nim
>>> "a"
a : string
>>> 'a'
Error: expression 'echo' is of type 'proc (x: varargs[typed]){.gcsafe, locks: 0.}' and has to be discarded; for a function call use ()
>>>

It should print:

a : char

🌵

[TODO] on error, we shouldn't discard valuable information

follow up from #29: my original bug report was actually only half valid / imprecise (sorry for any confusion!); let me clarify what I think is ideal default behavior:

let's reuse bugs/t59_array_index.nim: same as in #29

inim
👑 INim 0.3.1
Nim Compiler Version 0.18.1 [MacOSX: amd64] at /Users/timothee/.nimble/bin/nim
inim> import bugs/t59_array_index
Error: unhandled exception: index out of bounds [IndexError]

the useful context is lost here.

  • @["a", "b", "c"] stdout normal output should be shown (but i think that's just #30)
  • the error should be:
/Users/timothee/git_clone/nim/timn/bugs/t59_array_index.nim(3) t59_array_index
/Users/timothee/git_clone/nim/Nim/lib/system.nim(3597) []
/Users/timothee/git_clone/nim/Nim/lib/system.nim(2807) sysFatal
Error: unhandled exception: index out of bounds [IndexError]

which shows the relevant useful runtime stacktrace
the only non-relevant information, that we can discard, is:
Error: execution of an external program failed: '/tmp/nim//app '

NOTE: this is also how ipython3 does it.

ipython3
Python 3.6.5 (default, Jun 20 2018, 01:40:23)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import t01_inim_issue_29
['a', 'b', 'c']
a
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-1-7cfa22fd8457> in <module>()
----> 1 import t01_inim_issue_29

~/git_clone/nim/timn/tests/python/t01_inim_issue_29.py in <module>()
      2 print(a)
      3 print(a[0])
----> 4 print(a[3])
      5

IndexError: list index out of range
  • TODO: and in their case, they show more source info which could be nice as an enhancement

NOTE: same with inim -s=bugs/t59_array_index.nim, the useful error should be:

inim -s=bugs/t59_array_index.nim
inim_1531876765
/Users/timothee/git_clone/nim/Nim/lib/system.nim(3597) []
/Users/timothee/git_clone/nim/Nim/lib/system.nim(2807) sysFatal
Error: unhandled exception: index out of bounds [IndexError]

ie, only Error: execution of an external program failed: '/private/tmp/inim_1531876765 ' would be discarded

NOTE: the existing behavior is correct in the following case:

inim
👑 INim 0.3.1
Nim Compiler Version 0.18.1 [MacOSX: amd64] at /Users/timothee/.nimble/bin/nim
inim> asdf
Error: undeclared identifier: 'asdf'
inim>

since there's no relevant stacktrace

summary

  • for runtime errors (after compilation of given cmd succeeds and program is ran, then errors), show runtime stacktrace (discard just "Error: execution of an external program failed" which actually isn't even part of runtime error, just the wrapping exec cmd)
  • for compile errors, existing behavior (eg just showing: "Error: undeclared identifier: 'asdf'") is problably ok but I need to double check on more complex failures; eg, we problably don't want to filter out "template/generic instantiation from here" compilation error messages since these contain useful information to figure out why compile failed

[feature] `foo | inim -s:-` to read foo from stdin as if it were a script

cat foo.nim | inim # executes foo.nim line by line, using inim specific semantics (eg see https://github.com/AndreiRegiani/INim/issues/36)
inim -s:foo.nim # this doesn't use line-by-line interpretation

# proposal: this would have same semantics as `inim -s:foo.nim`
cat foo.nim | inim -s:-

compared to -s:foo.nim, it adds flexibility of unix pipes, or of avoiding user to write to an temporary file, etc.

NOTE: nim itself actually understands - as meaning "stdin"

echo "echo 1" | nim c -o:app -r -

so there's nothing surprising there

BUG: `cat foo.nim | inim` broken; should use same strategy as in ipython (detect end of scope by an empty line)

ipython works

tests/python/t02_inim_std_issue.py:

"""
works:
cat tests/python/t02_inim_std_issue.py | ipython3
"""
print("foo")
print("bar1")

for i in range(10):
  print(i)

print("bar2")

Note: ipython can't work with the following (as is expected)
tests/python/t02_inim_std_issue2.py:

print("foo")
print("bar1")

for i in range(10):
  print(i) # no empty line, won't work
print("bar2")

inim doesn't work:

cat bugs/inim/t04_stdin_broken.nim | inim --showHeader:f
foo
bar
# fails

bugs/inim/t04_stdin_broken.nim:

echo "foo"
echo "bar"

for i in 0..10:
  echo i

echo "bar"

Note: I wouldn't expect it to work in this case (as in the ipython case)
bugs/inim/t04_stdin_broken2.nim:

echo "foo"
echo "bar"

for i in 0..10:
  echo i
echo "bar"

summary

cat bugs/inim/t04_stdin_broken.nim | inim --showHeader:f
should work

cat bugs/inim/t04_stdin_broken2.nim | inim --showHeader:f
for this case, I believe it can also be made to work, but maybe a bit more tricky to implement:
instead of reading stdin line by line (or with multiline pase, see #8), read stdin until eof, and interpret accordingly: this should work in both interactive input and non-interactive input.
Note: maybe another way would be by detecting whether we're a tty.

BUG: newlines not printed to stdout, produces different output from nim

test.nim:

proc foo()=
  echo "test1"
  echo ""

  echo "test2"
  echo "\n"

  echo "test3"
  var s:string = nil
  echo s


  echo "test4"
  echo "a\n"

  echo "test5"
  echo "a\nb\n"

  echo "test6"
  echo "a\n\n"

  echo "done"
foo()
 inim
INim 0.2.5
Nim Compiler Version 0.18.1 [MacOSX: amd64] at /Users/timothee/.nimble/bin/nim
>>> import bugs/t38_echo
test1
test2
test3
test4
a
test5
a
b
test6
a
done
nim c -o:app -r test.nim
test1

test2


test3

test4
a

test5
a
b

test6
a


done

Shortcut to print values of discarded symbols: fails on OSX, works on ubuntu

ubuntu:

inim
INim 0.2.5
Nim Compiler Version 0.18.0 [Linux: amd64] at /home/ubuntu/.linuxbrew/bin/nim
>>> 1+1
2 : int literal(2)

OSX:

inim
INim 0.2.5
Nim Compiler Version 0.18.1 [MacOSX: amd64] at /Users/timothee/.nimble/bin/nim
>>> 1+1
Error: expression '2' is of type 'int literal(2)' and has to be discarded
  1+1
   ^
>>>

Can't install inim.

C:\Users\User>nimble install inim
Downloading https://github.com/AndreiRegiani/INim using git
Verifying dependencies for [email protected]
Info: Dependency on cligen@>= 0.9.15 already satisfied
Verifying dependencies for [email protected]
Installing [email protected]
Building inim/inim.exe using c backend
Prompt: Build failed for '[email protected]', would you like to try installing 'inim@#head' (latest unstable)? [y/N]
Answer: y
Downloading https://github.com/AndreiRegiani/INim using git
Verifying dependencies for inim@#head
Info: Dependency on cligen@>= 0.9.15 already satisfied
Verifying dependencies for [email protected]
Installing inim@#head
Building inim/inim.exe using c backend
Tip: 13 messages have been suppressed, use --verbose to show them.
Error: Build failed for package: inim
... Details:
... Execution failed with exit code 1
... Command: "C:\Users\User\Downloads\nim-0.19.0\bin\nim.exe" c --noBabelPath -d:release --path:"C:\Users\User.nimble\pkgs\cligen-0.9.16" -o:"C:\Users\User\AppData\Local\Temp\nimble_3652\githubcom_AndreiRegianiINim_#head\inim.exe" "C:\Users\User\AppData\Local\Temp\nimble_3652\githubcom_AndreiRegianiINim_#head\src\inim.nim"
... Output: Hint: used config file 'C:\Users\User\Downloads\nim-0.19.0\config\nim.cfg' [Conf]
... Hint: system [Processing]
... Hint: inim [Processing]
... Hint: os [Processing]
... Hint: strutils [Processing]
... Hint: parseutils [Processing]
... Hint: math [Processing]
... Hint: bitops [Processing]
... Hint: algorithm [Processing]
... Hint: unicode [Processing]
... Hint: times [Processing]
... Hint: options [Processing]
... Hint: typetraits [Processing]
... Hint: strformat [Processing]
... Hint: macros [Processing]
... Hint: winlean [Processing]
... Hint: dynlib [Processing]
... Hint: ospaths [Processing]
... Hint: osproc [Processing]
... Hint: strtabs [Processing]
... Hint: hashes [Processing]
... Hint: streams [Processing]
... Hint: cpuinfo [Processing]
... Hint: rdstdin [Processing]
... Hint: terminal [Processing]
... Hint: colors [Processing]
... Hint: tables [Processing]
... inim.nim(79, 16) Error: type mismatch: got but expected 'string'

wrong error when imported file ends with expression

mybug.nim:

let a = @["a", "b", "c"]
echo a
a
inim
import mybug
/private/tmp/inim_1531877xxx.nim(1, 6) Error: undeclared identifier: 'a'

here we probably want to give nim's error un-modified:

mybug.nim(3, 1) Error: expression 'a' is of type 'seq[string]' and has to be discarded
a

on error, should flush stdout

in both cases of #29, there's a flush missing:
the result of 1st echo isn't shown

whereas nim itself does flush:

nim c -o:app -r bugs/t59_array_index.nim
...
@["a", "b", "c"] # <= HERE
/Users/timothee/git_clone/nim/timn/bugs/t59_array_index.nim(3) t59_array_index
/Users/timothee/git_clone/nim/Nim/lib/system.nim(3597) []
/Users/timothee/git_clone/nim/Nim/lib/system.nim(2807) sysFatal
Error: unhandled exception: index out of bounds [IndexError]
Error: execution of an external program failed: './app '

inim should read configs read by nim (eg nim.cfg) but doesn't

test.nim:

import foo/util
nim c -o:app -r test.nim
#works, because I set the path in nim.cfg

inim

>>> import foo/util
Error: cannot open file: foo/util
  import foo/util
             ^

Also, it shouldn't duplicate the logic (which can change over time and be complex) but call the logic used by nim.

recent commit broke Nim CI

/cc @0atman
is there no CI in place that would've caught this?

https://dev.azure.com/nim-lang/255dfe86-e590-40bb-a8a2-3c0295ebdeb1/_apis/build/builds/4285/logs/75

2020-04-14T09:38:46.2229348Z Hint: killring [Processing]
2020-04-14T09:38:46.2229583Z Hint: deques [Processing]
2020-04-14T09:38:46.2230813Z /home/vsts/work/1/s/pkgstemp/inim/src/inim.nim(366, 6) Hint: 'main' is declared but not used [XDeclaredButNotUsed]
2020-04-14T09:38:46.2231992Z /home/vsts/work/1/s/pkgstemp/inim/src/inim.nim(4, 69) Warning: imported and not used: 'streams' [UnusedImport]
2020-04-14T09:38:46.2232585Z /home/vsts/work/1/s/pkgstemp/inim/tests/test.nim(4, 8) Error: type mismatch: got <>
2020-04-14T09:38:46.2232952Z but expected one of: 
2020-04-14T09:38:46.2233299Z proc initApp(nim, srcFile: string; showHeader: bool; flags = "")
2020-04-14T09:38:46.2233567Z 
2020-04-14T09:38:46.2233917Z expression: initApp()
2020-04-14T09:38:46.2234545Z        Tip: 22 messages have been suppressed, use --verbose to show them.
2020-04-14T09:38:46.2234948Z      Error: Execution failed with exit code 1
2020-04-14T09:38:46.2236384Z         ... Command: "/home/vsts/work/1/s/bin/nim" c --noNimblePath -d:NimblePkgVersion=0.4.3 --path:"/home/vsts/.nimble/pkgs/cligen-0.9.43" --path:"/tmp/nimble_27096/githubcom_jangkonimnoise" "-r" "--path:."  "/home/vsts/work/1/s/pkgstemp/inim/tests/test"
2020-04-14T09:38:46.2237088Z 
2020-04-14T09:50:20.6926852Z �[32mPASS: �[36mhttps://github.com/narimiran/itertools C                    �[34m ( 3.49 sec)�[0m

can also repro via:

NIMBLE_DIR=$HOME/.nimble_fake14 nimble test

  Executing task test in /Users/timothee/git_clone/nim/temp/INim/inim.nimble
/Users/timothee/git_clone/nim/temp/INim/inim_95807.nims(5, 22) Warning: imported and not used: 'strutils' [UnusedImport]
  Verifying dependencies for [email protected]
      Info: Dependency on cligen@>= 0.9.15 already satisfied
  Verifying dependencies for [email protected]
      Info: Dependency on noise@any version already satisfied
  Verifying dependencies for [email protected]
  Compiling /Users/timothee/git_clone/nim/temp/INim/tests/test (from package inim) using c backend
/Users/timothee/git_clone/nim/temp/INim/tests/test.nim(1, 1) template/generic instantiation from here
/Users/timothee/git_clone/nim/temp/INim/src/inim.nim(4, 69) Warning: imported and not used: 'streams' [UnusedImport]
  import os, osproc, strformat, strutils, terminal, times, strformat, streams
                                                                      ^
/Users/timothee/git_clone/nim/temp/INim/tests/test.nim(4, 8) Error: type mismatch: got <>
but expected one of:
proc initApp(nim, srcFile: string; showHeader: bool; flags = "")

expression: initApp()
  initApp()
         ^

support `cd, ls, pwd` as in ipython

ipython supports cd, ls, pwd
these are very useful and commonly used.

2 ways to do that:

  • using magic commands (not regular procs) that would have to be recognized specially by inim interpretter
    eg:
cd mydir # would call setCurrentDir(mydir)
ls # would call something like osproc.execCmd("ls")
ls -al # likewise, osproc.execCmd("ls -a")
  • using normal procs that would not have to be treated specially by inim interpretter
    eg:
cd "mydir"
ls() #instead of ls
pwd() instead of pwd
call "ls -a" #  would call something like osproc.execCmd("ls -a")

I prefer the less magical option 2; pwd() is less nice than pwd as the only drawback but it's also much easer to implement and extend (simple import a module).

Either of these 2 options can be enabled via, say, inim -with_tools

[WIP] feature wish list

(closed until I clean this up)

TODO: see good ideas from ipython3 --help that would be relevant for inim and sort them here

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.