Why is the implicit `result` so widely used?

2020-11-21 Thread Araq
> Back in the ‘80s my main language was Pascal. Most/all(?) flavors of Pascal > had this restriction. They all had the `goto` instruction so I have no idea what you're talking about. :-)

tables.add() deprecation in favor of []= is wrong

2020-11-21 Thread cblake
You can always `tab.mgetOrPut(key, @[]).add(val)` to do a 1-lookup variant. There is, of course, memory indirection/allocation overhead.

tables.add() deprecation in favor of []= is wrong

2020-11-21 Thread mildred
Note: the linked benchmark at are wrong. There is overhead to using seq[T] over a table: adding an item must perform a lookup to know if a seq exists (then append to it and store it) or not.

std/tables [] vs. add()

2020-11-21 Thread inventormatt
You can try something like this which should give you the functionality you are looking for.

std/tables [] vs. add()

2020-11-21 Thread mildred
When replacing `Table[string,string]` with `Table[string,seq[string]]` how do you efficiently add an item to the table? I came up with: result[key] = concat(result.getOrDefault(key), @[value]) Run But it requires a lookup, a concat and a store. Is there a better way?

How to differentiate different IOErrors?

2020-11-21 Thread satoru
Thanks for your explanation. I can accept the subclass approach or adding an `errorCode` field. Having to use something like `os.osLastError()` just feels as low level as C.

Article on writing hacking tools in Nim

2020-11-21 Thread Niminem
hahaha Nice, just when I got finished watching Mr. Robot too

Why is the implicit `result` so widely used?

2020-11-21 Thread reneha
If there's a number of conditions to be checked before a proc does any actual work, then having to use if-else is cumbersome. But in this case it's quite likely that exceptions are being thrown instead of returning error values.

tables.add() deprecation in favor of []= is wrong

2020-11-21 Thread cblake
The in-stdlib replacement is `Table[K, seq[V]]`. The nimbleverse has at least `adix/lptabz` which tries to be close to the stdlib Table interfaces while extending functionality and configurability/flexibility in several dimensions.

How to differentiate different IOErrors?

2020-11-21 Thread cblake
At this point there might be some backward compatibility of exception handling concerns in terms of making `IOError` inherit from/merge with `OSError`. This might be another thing that fell through the cracks when @Araq did his pre-1.0 stdlib quality control scan. Simply adding an `errorCode` fi

Article on writing hacking tools in Nim

2020-11-21 Thread slonik_az
You know they say -- there is no such a thing as bad publicity :-) I remember there was a big discussion of a kind on Lua users mailing list when it was revealed that stuxnet virus had Lua VM embeded.

Why is the implicit `result` so widely used?

2020-11-21 Thread snej
> Many coding standards, e.g., MISRA, mandate only one return point from a > function. It is claimed that this leads to easier, less error prone > maintenance. Back in the ‘80s my main language was Pascal. Most/all(?) flavors of Pascal had this restriction. I found it forced me to write really

Article on writing hacking tools in Nim

2020-11-21 Thread snej
[Implant Roulette Part 1: Nimplant](https://secbytes.net/Implant-Roulette-Part-1:-Nimplant) describes how to write hacking/malware tools like shellcode in Nim. > Throughout this series, I will be exploring different languages and seeing > what they bring to the table for implant & offensive too

Article on writing hacking tools in Nim

2020-11-21 Thread Yardanico
Heh, didn't expect to see nim-strenc and nuglifier packages being mentioned :)

How to differentiate different IOErrors?

2020-11-21 Thread sschwarzer
> I do not know how one would ever detect IO errors besides from the OS. Seems the Python devs thought this, too. ;-) Python merged `IOError` and `OSError` a while ago: I also like the idea of sub

tables.add() deprecation in favor of []= is wrong

2020-11-21 Thread sschwarzer
There was a discussion on this recently:

tables.add() deprecation in favor of []= is wrong

2020-11-21 Thread mildred
Found some interesting discussion here:

tables.add() deprecation in favor of []= is wrong

2020-11-21 Thread mildred
Most keys are not duplicated, and fast indexing may help there. Only the odd key may need to iterate over the table to discover all its values. In fact, I got the impression that Tables were explicitly able to deal with duplicate keys, and I started using them for this purpose. If this is remove

tables.add() deprecation in favor of []= is wrong

2020-11-21 Thread Hlaaftana
Would `seq[(string, string)]` not suffice? I would assume you wouldn't need fast indexing and deletion since you dealt with multiple keys and were probably not already using them.

tables.add() deprecation in favor of []= is wrong

2020-11-21 Thread mildred
With Nim 1.4, there is a deprecation warning **Warning: Deprecated since v1.4; it was more confusing than useful, use `[]=`; add is deprecated** that I believe is wrong. `[]=` and `add` are doing two very different things for tables. * `add` is adding a new pair to the table, which may result

Error: type mismatch: got but expected 'int literal(8)'

2020-11-21 Thread xigoi
Try `Address(0x8000'u64)`.

How to differentiate different IOErrors?

2020-11-21 Thread cblake
`OSError` has an `errorCode` field. No idea why `IOError` does not. I do not know how one would ever detect IO errors besides from the OS.

Can we have an --exceptions:abort ?

2020-11-21 Thread orange
It's a bit sorry to hear that. I made sure the article is representative of what people think in the game industry before posting the link, or at least people with similar mindset to me. C++ exceptions are relevant because it's the best Nim can do in the traditional sense of exception handling

Can we have an --exceptions:abort ?

2020-11-21 Thread Araq
> The original article has more details, which I don't quote them in full here. No problem, I did read it completely. The article is terrible but going through all the points where I don't agree with it isn't too productive. But even if the "details" in that article were true for C++ (and they a

Error: type mismatch: got but expected 'int literal(8)'

2020-11-21 Thread AlectronikHQ
Indeed, this was it. Thanks!

How to differentiate different IOErrors?

2020-11-21 Thread satoru
Is there something like `errno` on the `IOError` object? The syntax of error handling seems very much like Python, when it seems I don't have access to things like errno here.

Error: type mismatch: got but expected 'int literal(8)'

2020-11-21 Thread gabbhack
I think that in your case, the compiler considers `[8, int8]` as a array constructor.

Error: type mismatch: got but expected 'int literal(8)'

2020-11-21 Thread Yardanico
Spacing matters: type SegDescPointer* = ptr array[8, int8] Run

Error: type mismatch: got but expected 'int literal(8)'

2020-11-21 Thread AlectronikHQ
The following code causes this error (found in nim-xv6): type SegDescPointer* = ptr array [8, int8] Run How to write this definition correctly?

How to differentiate different IOErrors?

2020-11-21 Thread cblake
Inside the exception handler clause you could test `os.osLastError()` against `posix.ENOENT` or `winlean.ERROR_PATH_NOT_FOUND`. I think you will need some `when` clause to make this portable (both for either module `import` statement and for the test which you might want to abstract into a `proc

How to differentiate different IOErrors?

2020-11-21 Thread satoru
When opening a file, an IOError might be raised by the `open` proc. I want to return some empty value only when the error is "file not found". How can I differentiate different IOErrors in Nim?

Can we have an --exceptions:abort ?

2020-11-21 Thread orange
I was referring to that article for performance implications of C++ exceptions in the context of game development: > There is a lot of debate as to whether this is acceptable for PC games, but > when it comes to consoles the issue becomes much more black and white. The original article has more