Le lundi 23 novembre 2015 à 05:32 -0800, Maxim Berman a écrit : > Hello, > > In Matlab, people often use structures to pass around arguments > between functions, for example problem instances. This allows some > flexibility in the development, since I don't have to think of all > variables that I need and their types, and new objects can be easily > added to existing structs > > In Julia, I tend to use Dicts to replicate this behavior, to pass > around options and helper structures to my functions. I don't think > this is recommended since it doesn't allow functions to specialize on > the type of objects contained in the Dict. > > Should I use custom types instead? If some fields can be of different > types, should I use an abstract type for my options and then use > different subtypes ? This seems a bit too complicated... On the other > hand, writing down all arguments in functions without using Dicts or > custom types can be tedious when they are a lot of variables... > > Thanks for your advice. I'd say yes, use custom types and parameterize them on the types of the fields that have no fixed type.
Also, using abstract types in function signatures cannot hurt, and it's only a pair of lines to add, so I'm not sure you're referring to that when you say "complicated". Maybe you could give us a short example? Regards
