[newbie question] Pointer to cstring

2017-01-26 Thread mmierzwa
Hi

I am having hard time understanding pointers, addr, cstrings.


var i: cstring = "a"
var pi: ptr cstring = i.addr
echo repr(i)
echo repr(pi)


Output: 


005BC058"a"
ref 004477F8 --> 005BC070"a"


My understanding is this. First we declare variable i and assign string "a" 
there. As first line of output says, "a" is kept in ...058 cell of memory so in 
fact i contains address of this cell. Now we are declaring pointer pi and 
assign address of i. Is it that pi points to i that points to ...058 memory 
which contains "a"? As I understand from second ouput line address of pi 
variable is ...77F8, but then it is suggesting that "a" is in memory cell C070. 
I am a bit confused. Could you help me understand? 


Re: Forum rules

2017-01-26 Thread Araq
> Take my last few posts for example. Some saints out there actually think that 
> my jokes are funny, and that my occasional "keep it copyfree" advocacy is not 
> particularly annoying.

Too bad for you then that one admin disagrees... 


Re: var param vs tuple as return value

2017-01-26 Thread Libman
I think that noobs (like myself) should be encouraged to avoid annoying the 
DevGods on GitHub with anything short of a fully-baked well-thought-out bug 
report, but message forums are a lower tier of seriousness, about on par with 
chat, where novices and noobs can help each-other.

Chat logs have a lower search result helpfulness value, so telling people to 
only ask noob questions in chat will result in more repetitive noob questions 
overall.

I [still](http://forum.nim-lang.org/t/2675/2#16772) think this forum needs more 
features, especially for categorizing threads. The poster or a moderator would 
tag a thread as a "n00b question", and people who don't like those could filter 
them out from their default thread listing. 


Re: Forum rules

2017-01-26 Thread Libman
The problem with the Golden Rule is that some values are subjective.

Take my last few posts for example. Some saints out there actually think that 
[my jokes](http://forum.nim-lang.org/t/2738/3#17079) are funny, and that my 
occasional ["keep it copyfree"](http://forum.nim-lang.org/t/2620/2#17150) 
advocacy is not particularly annoying. 


Re: Enum and repr prints invalid data

2017-01-26 Thread frelars
Same example but with all cases added.

I noticed while working on this example that the issue would disappear and 
surface again simple by changing the object and function names (no semantic 
difference). But this version is tested and shows the issue


type
  Status = enum
Ok, Error
  
  Ret8 = object
status:Status
data:uint8
  
  Ret32 = object
status:Status
data:uint32

proc test8():Ret8 =
  return Ret8(status:Ok,data:0)

proc test32():Ret32 =
  return Ret32(status:Ok,data:0)

let local = Ret8(status:Ok,data:0)
echo "local ", repr(local) # Ok

let a = test8()
echo "a ", a   # OK
echo "a ", repr(a) # Error

let b = test32()
echo "b ", b   # OK
echo "b ", repr(b) # OK



Enum and repr prints invalid data

2017-01-26 Thread frelars
Hi

There seems to be an issue with repr on returned stack objects containing 
enums. See example below.

If I create the Ret object in local stack frame, it works. If I change Ret.data 
to uin32 it works even if returned from a function.


type
  Status = enum
Ok, Error
  
  Ret = object
status:Status
data:uint8

proc test():Ret =
  return Ret(status:Ok,data:0)

let a = test()
echo "a ", a # Ok
echo "a ", repr(a)   # Prints "invalid data" for the status field



Re: Forum rules

2017-01-26 Thread dom96
The rule is: Utilise common sense and [the Golden 
Rule](https://en.wikipedia.org/wiki/Golden_Rule).


Re: messaging - or communicating between GUI's

2017-01-26 Thread mmierzwa
Thank you for your reply **Krux02**, I appreciate it. Not quite there however 
because what I am interested in is processes not threads and how to set up 
communication between two. Also I am looking for pipes, shared memory, ffs and 
differences among them, performance etc. I do not want to setup communication 
through sockets. Nothing to do with GUI applications.

**god**, thank you I think exactly what I am looking for. Will check your 
examples. 


Re: Forum rules

2017-01-26 Thread flyx
There are no official rules. There have been threads about having a CoC and the 
majority was against it. General opinion usually is _„instead of thinking about 
rules, just write some Nim code“_. There also isn't some big sign on your front 
door which tells you how to behave while out on the street, yet people get 
along with each other most of the time.


Re: messaging - or communicating between GUI's

2017-01-26 Thread god
mmierzwa, as I'm on windows, I used Windows Named Pipes (not ipc)

I adapted some example cpp code (see comments in paste) to get a basic 
server->client in nim.

A bit of a simple hack (one direction messaging), but it worked for my needs.

Here's an example, inc a basic test

[server](http://pastebin.com/GJA4Q9w8)

[client](http://pastebin.com/ApRqaHFc)


Re: Forum rules

2017-01-26 Thread Krux02
Good point, I don't rememeber any official forum rules. But I can give you some 
recommendations if you want to:

>   * Be nice.
>   * Don't start a flamewar.
> 



Forum rules

2017-01-26 Thread AironGregatti
I am new to the forum, like all forums, there are a set of rules that should be 
followed, I wanted to know what they are for this forum.