> how do I get a pointer to its items

Well you did it the right and common way in your first post:
    
    
    socket.send(addr data[0], data.len)
    
    
    Run

When we have var s1: seq[T] then addr(s1[0]) is the address of the first 
element. But as I told you, the dereference s1[0] may fail when the seq is 
uninitialized, as it is a nil deref.
    
    
    proc main =
      var s1: seq[int]
      var s2 = newSeq[int]()
      
      echo cast[int](s1)
      echo cast[int](s2)
      
      var a: ptr int = addr(s1[0])
    
    main()
    
    
    Run
    
    
    $ ./t
    0
    140675632484432
    /tmp/t.nim(10)           t
    /tmp/t.nim(8)            main
    /home/salewski/Nim/lib/system/fatal.nim(49) sysFatal
    Error: unhandled exception: index out of bounds, the container is empty 
[IndexDefect]
    
    
    Run

And indeed we get the same error for s2, so you have to test for len == 0 
before using subscript operator []. 

Reply via email to