Re: SIGSEGV: Illegal storage access. (Attempt to read from nil?) 3
ISSUE RESOLVED. I fixed the error by checking for attrsLen property like this: import htmlparser import xmltree import strtabs import strutils let allhtml:File = open("allhtml.txt") var line: string var count = 0 while allhtml.readline(line): echo "HTML file: ", count, line let html = loadHTML(line.strip()) for a in html.findall("a"): if a.attrsLen > 0: let url = a.attrs.getOrDefault("href") if not url.isNil: if url.startswith("/"): echo "$1\t$2" % [line, url] count += 1 close(allhtml)
Re: SIGSEGV: Illegal storage access. (Attempt to read from nil?) 3
nope. it did not make any difference. import htmlparser import xmltree import strtabs import strutils let allhtml:File = open("allhtml.txt") var line: string var count = 0 while allhtml.readline(line): echo "HTML file: ", count, line var html = loadHTML(line.strip()) for a in html.findall("a"): var url = a.attrs.getOrDefault("href", "/") if not url.isNil and url.startswith("/"): echo "$1\t$2" % [line, url] count += 1 close(allhtml)
SIGSEGV: Illegal storage access. (Attempt to read from nil?) 3
The code import htmlparser import xmltree import strtabs import strutils let allhtml:File = open("allhtml.txt") var line: string while allhtml.readline(line): echo "HTML FILE: ", line var html = loadHTML(line.strip()) for a in html.findall("a"): var url = a.attrs.getOrDefault("href", nil) if not url.isNil and url.startswith("/"): echo "$1\t$2" % [line, url] close(allhtml) The error: Traceback (most recent call last) rewrite.nim(26) rewrite strtabs.nim(133) getOrDefault strtabs.nim(104) rawGet strtabs.nim(85) myhash SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Re: nim-cookbook
Thanks! I'm still finding my way around Nim and this is helpful.
nim-cookbook
I have started writing a Nim Programming Cookbook similar to those in Python, Perl etc., The website is [http://nim-cookbook.btbytes.com](http://nim-cookbook.btbytes.com)/ . The source code to the cookbook is on github - [https://github.com/btbytes/nim-cookbook](https://github.com/btbytes/nim-cookbook)/ Please do share what topics you would like to see in the cookbook. PRs welcome!
Re: Is Nim better than C?
**Language X** can be used as a replacement for C language(used as a better C), where **Language X** can be anywhere from C++, Java, D, Python, Go, OCaml, Erlang, Javascript etc., depending on what you are trying to do. Being better than C at _something_ is not that difficult. Today C is chosen mostly because old habits die hard, not because it's the "best language overall".
Re: QtCreator plugin
Hi @filcuc, I just downloaded the the latest from the above link.. It still doesn't have the nim parts.