h3rald / min

A small but practical concatenative programming language and shell
https://min-lang.org
MIT License
311 stars 23 forks source link

code in description of http module doesn't work #43

Closed zenon closed 4 years ago

zenon commented 4 years ago

In the documentation, 6.15 http Module, the server example doesn't work.

  1. Error: Symbol: tap - Incorrect values found on the stack I removed tap.

  2. Error: Handler is not a quotation. Remark: It is confusing that the word "Handler" is uppercase. I inserted the handler quotation directly into directory. Now it starts. Yeah!

  3. When accessing http://127.0.0.1:5555/nope Error: Response body is not a string. I tried adding body string @body before {body :body} But it did't help. I changed the line {body :body} to {"hm" :body} Making the server functionality void.

  4. Error: Response headers are not in a dictionary. I changed that line to {"hm" :body {} :headers}

  5. Error: 'qVal' is not accessible using discriminant 'kind' of type 'MinValueObject'

Now I'm stuck :-)

h3rald commented 4 years ago

Ohhh tricky. My guess is that something broke through the different releases of Nim. I do have some tests but clearly not enough, and the http module is probably a little bit under-tested (especially the server part).

Will hopefully try to make sense out of it this weekend, if I get a chance.

h3rald commented 4 years ago

Now I had to update the example quite a bit... essentially dictionary literals are still a bit tricky and I think there's a chance that they may not work as expected. Fortunately, creating an empty dictionary and then setting keys seems to work much better... so for now I updated the example to follow this technique.

zenon commented 4 years ago

Fabio. You are incredible!

Many thanks for this speed. Stopping the webserver works.

I had to add

{} %headers 

to the response gain. Now it fails with

SIGSEGV: Illegal storage access. (Attempt to read from nil?)

Ah. Interesting. Thats the self compiled code from yesterday. Todays version under windows works fine (0.19.6), even without the added {} %headers. Has there been any code change? Well. Bat that's not for today. Maybe tomorrow evening, maybe later.

Thank you for the help, and, of course, for min in the first place!

Kind greetings from Hamburg,

z.

h3rald commented 4 years ago

Yeah, I had to change something 😬 -- basically I rushed a little bit when I introduced the new dictionary syntax and forgot to use it in this specific case... see https://github.com/h3rald/min/commit/ecd4ef1c31b2bec6e6f85e39cb1344eb9fb87c2d#diff-1cc5d3274b68066b7e96be46d63db452