Inferring type of zero-sized collection from usage

2023-08-25 Thread Isofruit
This is a copy paste of sky_khan's earlier post. This puts you under strong suspicion of being a chat bot. Your account is therefore moderated going forward until further posts indicate otherwise.

Mastering Nim 2.0

2023-08-25 Thread ringabout
Congratulations on this masterpiece on the Nim language! It has a pretty cover and a comprehensive guide on the threading model in Nim! Nice work!

Mastering Nim 2.0

2023-08-25 Thread Araq
> P.S.: I am totally fine with review bribes ex post facto. Can send you signed copy, but it will take a while as I'm waiting for the hard covers to arrive.

Mastering Nim 2.0

2023-08-25 Thread elcritch
> It contains a new chapter "Mastering parallelism" which I consider my piece > of work so far, but in German we say "Eigenlob stinkt", so sorry about that. I'm taking that you mean "my _best_ piece of work so far"? ;) The chapter on "Mastering Parallelism" is good! I helped review the chapter

Mastering Nim 2.0

2023-08-25 Thread Araq
> If so, how can we get an Indian Reprint? I have no idea, sorry.

One language to rule them all.

2023-08-25 Thread radekm
Church-Turing thesis says that certain theoretical computation models compute same functions (or in simpler words solve same problems). Unfortunately these models are theoretical and assume unbounded memory. Church-Turing thesis also doesn't bother with the "speed" of these models or how comfor

Re: std/Paths - Converting Path to string

2023-08-25 Thread Araq
Probably but I hesitate because people use `$` without thinking and so could weaken the abstraction and reintroduce the problems a dedicated Path type tries to solve. But probably the "consistency" argument wins in this case.

Re: std/Paths - Converting Path to string

2023-08-25 Thread DMisener
I noticed the following anomaly: import std/paths nim> let path = Path "/dir/root.ext" nim> echo $path Error: type mismatch Expression: $path [1] path: Path Expected one of (first mismatch at [position]): [1] func `$`(x: float | float32): string

One language to rule them all.

2023-08-25 Thread Araq
For a complete opposite view, consider quantum computing and maybe also GPU programming: Old languages and models do not cut it and new programming languages have to be invented. ;-)

One language to rule them all.

2023-08-25 Thread Araq
These days I prefer to phrase it as "good for everything" which captures the idea much better. Use the same programming language for OS development, scientific computing, scripting, game development, . It not hard to design a language that does it, Nim is my attempt but plenty of languages do t

One language to rule them all.

2023-08-25 Thread bsljth
I've been a big fan of this idea ever since I started becoming serious about programming (aka when I got my first IT job 2 years ago). I'm a "learnt from the Internet" programmer who's been doing different things with JavaScript since 2021 (and a computing hobbyist from about 2014; and a lawyer

GuildenStern web server 6.0.0 is here

2023-08-25 Thread ITwrx
1. great! Sounds good. 3. Just to be clear: i'm not expecting anyone to code anything. Just trying to find out what Guildenstern can do in relation to my use case. Thanks for all the info.

Using asm or intrinsic C functions from Nim

2023-08-25 Thread mratsim
> I am looking into using the PDEP/PEXT machine instructions as part of Nim > proc:s and it seems to me that the asm keyword requires that you somehow know > which registers contains which variable. No you can use GCC/Clang extended ASM.

Mastering Nim 2.0

2023-08-25 Thread basilajith
Oh, I just read on Amazon that it's published independently. If so, how can we get an Indian Reprint?

Mastering Nim 2.0

2023-08-25 Thread bsljth
The above "DeletedUser" is me. I just realised that I couldn't rename my username without deleting my account. So, just did that.

Mastering Nim 2.0

2023-08-25 Thread basilajith
Mastering Nim, 1st edition is not available in India @Araq. Kindly persuade your publisher to do an Indian Reprint (of both editions; if that is necessary), so that we can get it here under a purchase parity price.

Inferring type of zero-sized collection from usage

2023-08-25 Thread juancarlospaco
https://notbyai.fyi

Inferring type of zero-sized collection from usage

2023-08-25 Thread sundar33w
That may be possible in script languages but nim is static typed compiled language. Type of "a" variable must be known on compile time. You cant change type of variable on runtime. So why not you go and declare "a : seq[string]" anyway ? Because what you're asking has no substantial benefit.

Mastering Nim 2.0

2023-08-25 Thread Araq
The 2nd edition of my book "Mastering Nim -- A complete guide to the programming language" is now available on Amazon: It contains a new chapter "Mastering parallelism" which I consider my piece of work so far, but in

Type mismatch when trying to add to custom seq

2023-08-25 Thread snorlax14
Right, I see. Thanks for the explanation :)

Circular imports for procs

2023-08-25 Thread iffy1
Those are my friend! I think that will work. Thank you!

Type mismatch when trying to add to custom seq

2023-08-25 Thread PMunch
It's a subtle bug, but essentially your object isn't mutable, so the sequence isn't mutable. The type error is because it's `seq[Terminal]` and `add` requires a `var seq[Terminal]`. Replacing `schematicConnect` with this works: proc schematicConnect(schematic: var Schematic, termina

Type mismatch when trying to add to custom seq

2023-08-25 Thread pp
Works using intermediate variables (and one var in proc definition):

GuildenStern web server 6.0.0 is here

2023-08-25 Thread Allin
1. The documentation is lacking here. StreamingContext is a subclass of HttpContext, so every way you can reply with httpserver, you can reply with streamingserver. So this should already solve your use case. 2. Allow me to replace the term "symmetric" with term "identical". I hope this reph

Type mismatch when trying to add to custom seq

2023-08-25 Thread snorlax14
Tried to reconstruct it using your playground but it doesn't produce the same error so here's the exact code. Sorry if it's a bit unreadable :/

Type mismatch when trying to add to custom seq

2023-08-25 Thread pp
This works for me trying to reconstruct missing parts:

Using asm or intrinsic C functions from Nim

2023-08-25 Thread radekm
Yes, I think using C intrinsics makes sense. Same approach is used by

Type mismatch when trying to add to custom seq

2023-08-25 Thread snorlax14
`adjacencyList.connections.add(terminal)` is the exact line that causes the error. `adjacencyList` is a `seq[Terminal]` and terminal has type `Terminal`

Using asm or intrinsic C functions from Nim

2023-08-25 Thread Yardanico
> you somehow know which registers contains which variable. You can use the backticks to get existing variables, see the docs at

Type mismatch when trying to add to custom seq

2023-08-25 Thread xigoi
Can you provide an example of the code where you're adding to a sequence?

Type mismatch when trying to add to custom seq

2023-08-25 Thread snorlax14
I've defined a custom type in my nim script, here's the definition: type Terminal = tuple name: string terminalType: TerminalType # enum defined elsewhere in the program parentComponent: ref Component # type defined elsewhere in the progra

Using asm or intrinsic C functions from Nim

2023-08-25 Thread koistinen
I am looking into using the PDEP/PEXT machine instructions as part of Nim proc:s and it seems to me that the `asm` keyword requires that you somehow know which registers contains which variable. So I am thinking using the intrinsic C functions like: `unsigned __int64 _pext_u64(unsigned __int64

Inferring type of zero-sized collection from usage

2023-08-25 Thread xigoi
> I think we may expect the new generation of computer languages in the next > couple of years, with ML support, things like add types to untyped code looks > like easy for ML to solve. Sounds like a great way to slow down compilation by several orders of magnitude and randomly introduce myster

Inferring type of zero-sized collection from usage

2023-08-25 Thread alexeypetrushin
Types are useful in some places and not so much in others. Usually it's useful to define inputs and outputs for block of code. Like types for the signature and return of a function. As for what's inside of that block of code - usually it's trivial to read it without types. Say you have function

Wishlist: Ideal UI library for Nim

2023-08-25 Thread matkuki
> @elcritch started to work on it. I'm sure he does not mind help. I second that 👍👍👍 @elcritch 's `Figuro` is shaping up nicely! Anyone with time, please help testing it!

Inferring type of zero-sized collection from usage

2023-08-25 Thread sky_khan
That = Changing type of variable on runtime or infer type of variable to apply optimizations. Maybe because I'm old but I'd prefer to see type of variable where it's declared. I just dont see the point of this kind of inference for Nim.