Nim is a compiled, garbage-collected systems programming language which has an excellent productivity/performance ratio. Nim's design focuses on efficiency, expressiveness, elegance (in the order of priority).
lc
- the current syntax is IMO clumsy, so while i prefer list comprehensions in python, i use map
in nim
=>
Hello and I'm sorry if my question is missing something very basic but, I seem to have encountered another issue
Trying to compile my very basic function
proc delayedStringGet(path: string) : Future[string] {.async.} =
var response = await client.request(url=(Host & path), body=body)
return response.body
Gives me this compile-time error. I seem to be matching the prototypes pretty accurately, so can't figure out what I'm doing wrong
proc request(client: AsyncHttpClient; url: string; httpMethod: string; body = "";
headers: HttpHeaders = nil): Future[AsyncResponse]
first type mismatch at position: 1
required type: AsyncHttpClient
but expression 'client' is of type: AsyncHttpClient
proc request(client: AsyncHttpClient; url: string; httpMethod = HttpGET; body = "";
headers: HttpHeaders = nil): Future[AsyncResponse]
first type mismatch at position: 1
required type: AsyncHttpClient
but expression 'client' is of type: AsyncHttpClient
=>
i could make from the top of my head: http://ix.io/1fSS/
import httpclient, asyncdispatch
let client = newAsyncHttpClient()
let Host = "123"
let body = "123123"
proc delayedStringGet(path: string) : Future[string] {.async.} =
var response = await client.request(url=(Host & path), body=body)
return response.body
@Araq btw, with code:
import httpclient, asyncdispatch
let client = newAsyncHttpClient()
let Host = "123"
proc delayedStringGet(path: string) : Future[string] {.async.} =
var response = await client.request(url=(Host & path), body=body)
return response.body
I get error:
tta.nim(7, 32) Error: type mismatch: got <AsyncHttpClient, url: string, body: None>
but expected one of:
proc request(url: string; httpMethod = HttpGET; extraHeaders = ""; body = "";
sslContext = getDefaultSSL(); timeout = -1; userAgent = defUserAgent;
proxy: Proxy = nil): Response
first type mismatch at position: 1
required type: string
but expression 'client' is of type: AsyncHttpClient
proc request(client: AsyncHttpClient; url: string; httpMethod: string; body = "";
headers: HttpHeaders = nil): Future[AsyncResponse]
first type mismatch at position: 1
required type: AsyncHttpClient
...etc
Is this normal? "body: None"