Re: Not-so-distinct types

2019-04-18 Thread boia01
If all you want is to prevent the equality operator (==), you can do: type I1 = distinct uint32 I2 = distinct uint32 converter toU32 (value: I1): uint32 = value.uint32 converter toU32 (value: I2): uint32 = value.uint32 proc `==`(i1: I1, i2: I2): bool

Re: Not-so-distinct types

2019-04-18 Thread Manny8888
I looked into converters, which I didn't know about. I thought the following might work: make all the type distinct, but automatic conversion to uint32 to remove the 'distinction' between sub-type and base type. type I1 = distinct uint32 I2 = distinct uint32

The Philosophies Of Software Languages

2019-04-18 Thread Libman
There's a recently-concluded series of four articles collectively titled " **The Philosophies Of Software Languages** " : * Foundations, 1940 to 1972, [From Plankalkül to C](https://www.welcometothejungle.co/fr/articles/philosophies-software-languages) (includes Fortran, Cobol, Algol,

Re: OpenWL/DL - two foundation libraries for building a cross-platform GUI with non-C++ languages

2019-04-18 Thread dewf
Note the menu aspect of my minimal example above isn't necessary - I just find it super convenient to have when testing so I'm never without a keyboard shortcut for exiting.

Re: OpenWL/DL - two foundation libraries for building a cross-platform GUI with non-C++ languages

2019-04-18 Thread dewf
So here's a minimal Mac example, current as of right now: [https://gist.github.com/dewf/d1de81fb9bbc7f1cd82d389f94f0e7e2](https://gist.github.com/dewf/d1de81fb9bbc7f1cd82d389f94f0e7e2) Bad news, though - I just pushed a [mass API

Re: OpenWL/DL - two foundation libraries for building a cross-platform GUI with non-C++ languages

2019-04-18 Thread treeform
I use MinGW with nim on windows all the time. I have never heard of winpty or MSYS2. To get rid of the console for a windows app from nim we just pass \--app:gui not sure what you need to do in C++ to do that. I manage to get some of OpenWL working on Mac with the help of @shashlick's modified

Can we suppress =destroy call for a local var?

2019-04-18 Thread Stefan_Salewski
Replacing finalizers with destructors for gintro seems to work in principle, at least I got cairo_anim.nim running with a few hacks. Problem is similar as with finalizers -- for callback vars owned by gtk we do not want a finalizer or destroy call, while for ordinary use we want the call. For

Re: Example implementing SQLite extension in Nim

2019-04-18 Thread chrisheller
I've been testing this with a similar setup to yours, but maybe we have different options for the SQLite library we're testing against. The default SQLite install on my Mac didn't have loadable extension support compiled in, so I tested with a separate SQLite amalgamation. Its the same version

Re: Not-so-distinct types

2019-04-18 Thread mashingan
If the mapping is fixed, you can use [subrange](https://nim-lang.org/docs/manual.html#types-subrange-types) types. Although the base type is same, you can define like type Row1 = range[ 0 .. 71 ] # assuming row has 72 bytes Row2 = range[ 72 .. 143 ]

Re: Not-so-distinct types

2019-04-18 Thread Manny8888
As you guessed, the content of the memory map will be variants. The memory will contain uint32 from time to time. But it will also be int32, float32, addresses, and other things. The hardware I am looking at emulating is the OpenGenera lisp machine where memory content was tagged. So it seems

Re: Not-so-distinct types

2019-04-18 Thread mashingan
Is [distinct](https://nim-lang.org/docs/manual.html#types-distinct-type) not what you need? You can define the needed operations from its base type using `borrow` pragma so you don't have to cast/coerce every time you use it Also, I did what @cdome suggested, defining `converter` s and it

Re: Not-so-distinct types

2019-04-18 Thread Stefan_Salewski
I guess that will not work: When your "memory map" is just a plain array of uint32 types, then all entries are equal. That is because in Nim by design all elements of an array have the same type, and more importantly, unit32 is just 32 bit, which is used all for storing numbers, there is no bit

Re: Will an object instance passed to a proc not generate a =destroy call?

2019-04-18 Thread Stefan_Salewski
Maybe now I understand: Proc parameters are unmutable in Nim, so there is no reason to destroy the copy. Only when inside the proc we have var myVal = myprocPar then we get a new mutable instance, which is destroyed. And my feeling is that = proc is never used for passing parameters to procs,

Re: Not-so-distinct types

2019-04-18 Thread Stefan_Salewski
> All true or all false is not what I am looking for though. Do you want to compare types or values? You can compare values only, when the types are compatible, that is when types are equal or when there is a converter. In your initial post you compared values, that worked because your types

Re: Not-so-distinct types

2019-04-18 Thread Manny8888
Correct. I get the equivalent (if I am not wrong this time) of Haskell's newtype declaration. I am looking for an half-way street. The benefit of static typing without the hard work of casting/coercion Basically I want the compiler to do everything for me without being a pain when I don't

Re: Not-so-distinct types

2019-04-18 Thread Manny8888
I apologise. You are right. I completely inverted the results. They are all true. All true or all false is not what I am looking for though.

Re: Will an object instance passed to a proc not generate a =destroy call?

2019-04-18 Thread Stefan_Salewski
I can rewrite it this way: O {.bycopy.} = object i: int proc new(o: var O) = echo "new called" proc `=destroy`*(s: var O) = echo "=destroy called" proc `=sink`*(a: var O; b: O) = echo "=sink called" a.i = b.i proc

Will an object instance passed to a proc not generate a =destroy call?

2019-04-18 Thread Stefan_Salewski
I was just thinking about how I can prevent a call of destroy from within a proc, because for callbacks we do not want destroy calls for parameters owned by GTK. But it seems that this tests does not generate a destroy call for proc parameter at all? type O {.bycopy.} =

Re: HttpClient "Name or service not known"

2019-04-18 Thread geotre
Here's a way to replicate the bug: 1. Install mitmproxy and run it 2. Install the generated mitmproxy .pem file onto your machine 3. export http_proxy=http://127.0.0.1:8080 and export https_proxy=http://127.0.0.1:8080 4. Run curl https://forum.nim-lang.org/ outputs the html correctly

Re: HttpClient "Name or service not known"

2019-04-18 Thread dom96
I see. connectionUrl.hostname has something when you echo it the object but not when you echo the field itself, try using repr, it's possible that there is a 0 (end-of-string) character in that string.

Re: HttpClient "Name or service not known"

2019-04-18 Thread trtt
@dom96 I'd like to fix it but in one of my previous comments I presented something that shouldn't happen. If someone has a clue about that issue then I will be able to continue but otherwise I'm in the dark.

Re: Is allowing non-matching types for assignment overloading in the development timeline?

2019-04-18 Thread mratsim
By the way, to restrict conversion to literals you can use the {lit} constraint converter toIntAp(n: int{lit}): IntAp Run Otherwise some subtle bugs might be introduced where you or your user do not want because an int was converted silently to IntAp.

Re: Is allowing non-matching types for assignment overloading in the development timeline?

2019-04-18 Thread lotzz
Wow thanks, I didn't know about this use of converters. I can simplify a lot it code with this!

Re: Not-so-distinct types

2019-04-18 Thread cdome
Might work, untested idea: Define convertors from t1 to base and t2 to base

Re: HttpClient "Name or service not known"

2019-04-18 Thread dom96
It happens because either: 1\. You are doing something wrong, like not setting the http_proxy env var (Unlikely since it works for you in curl) 2\. There is a bug in the httpclient module (Likely as there were other bugs with the proxy support before) I don't use proxies, I also don't have

Re: Not-so-distinct types

2019-04-18 Thread andrea
Type1 and Type2 are not distinct types, they are just aliases. You are declaring a different name for the same type uint32, there is no subtyping here

Re: HttpClient "Name or service not known"

2019-04-18 Thread trtt
Why does this happen? Can we ever expect proper proxy support for nim? Because if we can't then I might as well just change language or use curl as a replacement.

Re: Not-so-distinct types

2019-04-18 Thread trtt
I get true for both: var v:uint32 = 1 type Type1 = uint32 var v1: Type1 = 1 type Type2 = uint32 var v2: Type2 = 1 echo(v1 == v2) echo(v == v1) Run nim 0.19.4

Not-so-distinct types

2019-04-18 Thread Manny8888
Hello all, (One week experience of learning Nim) I would like to take advantages of the static typing that would look a bit like distinct types, but not exactly. I would like the sub-types to be distinct, but each sub-type to be fully equivalent to the base type. For example: var v:uint32 = 1