Hi,
I am missing something obvious: How do I get a safe ref of a tuple or an object:
type
TObject = object
data: int
var o: TObject
o.data = 123
var po: ref TObject
po = ??? # I want a ref to o
I used cast[ref TObject] addr(o) - but this is unsafe. What is the safe way ? Or this this something I should not do ? Sorry to ask, but I did not find any information about this.
I am not sure if I understand this correct. Is the following safe to do ? Sorry I am confused and have the feeling, that I am missing something obvious here.
type
� TData = object
� � s: string
� TDataContainer = object
� � data: array[0..10, TData]
� PDataContainer = ref TDataContainer
��
� PData = ptr TData
var cont: PDataContainer
new(cont)
for i in 0..cont.data.high :
� cont.data[i].s = $i
# somewhere in the program
var pEl: PData = addr(cont.data[2])
# even more later I need new data
new(cont)
# can I access pEl safely here, or is the memory pEl points to collected ?
echo pEl.s
Hi Araq, thanks - I guess I have used the wrong language for too long ;-)
BTW the results I get from my tests make me dizzy. I have increase in speed by factor 3 and more against the same code in Delphi or fpc and factor 1.5 - 2 against D (LDC not DMD). For example: my compression library is now on the same level as snappy (compiled with gcc) - which claims to be the fastest - but mine has a better compression ratio for my needs. I know its the C compiler backend (almost no difference if I use vcc or gcc, had no luck so far running clang on windows), but using C was never an option for me.
I was on the jump to D, but now I am considering Nimrod for the next generation of our database server.
And - It is amazing how clean the code looks, if you transfer it to Nimrod!
Cheers, Adrian.
... but now I am considering Nimrod for the next generation of our database server.
Excellent news. I hope Nimrod is up for the task. I'll try my best to quickly fix any occurring issues.