vlang / v

Simple, fast, safe, compiled language for developing maintainable software. Compiles itself in <1s with zero library dependencies. Supports automatic C => V translation. https://vlang.io
MIT License
35.88k stars 2.17k forks source link

REPL - print should print; optional "?" not working #1243

Closed benman1 closed 4 years ago

benman1 commented 5 years ago

V version: 760034b6b177e8cafa175a969106e70de65a7eb6 (July 19, as on github)

Ubuntu 18.04

What did you do? In the REPL, I tried to execute the example from the documentation.

What did you expect to see?

v >> data := http.get('https://vlang.io/utc_now')? >> data '1551205308'

What did you see instead? First attempt:

>>> data := http.get('https://vlang.io/utc_now')? undefined:http` >>> import http #include <curl/curl.h> ^~~~~ compilation terminated. V panic: clang error`

http is part of the v standard library, so I would have expected to see at least a warning during installation that I need to install more libraries. I installed one of the libcurl-dev packages sudo apt install libcurl4-gnutls-dev

Next I got:

>>> import http >>> data := http.get('https://vlang.io/utc_now')? .neXT=.eof panic: .vrepl_temp.v:2 unexpected token:?``

So I tried without the ? >>> data := http.get('https://vlang.io/utc_now') >>> data 1563531174

So that's good, however: >>> print(data)

Nothing...

>>> println(data) 1563531203

>>> println('hello, world') hello, world >>> print('hello, world') >>> C.fflush(stdout) (nil)

ntrel commented 5 years ago

I've got a branch to make http.get return an optional BTW.

medvednikov commented 5 years ago

I had it on a branch for ever... It's an easy fix.

nedpals commented 4 years ago

Closed. LibCurl dependency has been removed and option propagation has been fixed.

For usage information, quit V REPL using `exit` and use `v help`
V 0.1.27 06540f0
Use Ctrl-C or `exit` to exit
>>> import net.http
>>> data := http.get('https://vlang.io/utc_now')?
>>> data.text
1590301090
>>>