Sure, would be good!

I generally use this pattern only inside more general, pure functions that, 
say, loop over an array or list of items, where the data that is being viewed 
into is guaranteed to exist. I avoid to use these unsafe functions directly / 
on an adhoc basis, and I never pass the results around.


Am 05.03.2015 um 12:19 schrieb Simon Danisch <sdani...@gmail.com>:

> Just be careful that foo does not go out of scope while you use the result of 
> "typevec!" 
> this basically makes typevec! unsafe right? So, it probably should be 
> prefixed like this.
> 
> Am Donnerstag, 5. März 2015 10:51:36 UTC+1 schrieb Tamas Papp:
> If I have a composite type 
> 
> type Foo 
>   a 
>   b 
>   c 
> end 
> 
> I can initialize it with a vector like this: 
> 
> x = Foo([1,2,3]...) 
> 
> But how can I get the fields as a vector, eg [x.a,x.b,x.c] without 
> enumerating them? convert(x, Vector) does not work. 
> 
> I need this to go back and forth between the type and the vector 
> representation of a set of parameters when using NLopt. 
> 
> Best, 
> 
> Tamas 

Reply via email to