Re: init DateTime is very annoying because we always need to initialize the DateTime object

2018-04-30 Thread mashingan
`DateTime` is reference-type, hence it's default to nil. If you're planning to use it later it's preferable to use `Time` since it's value-type and make wrappers to get the values you need later. When in doubt, use value-type. It's cheaper and easier to reason.

Re: init DateTime is very annoying because we always need to initialize the DateTime object

2018-04-30 Thread slangmgh
@GULPF I need to define the variable first, then initialize the object later according to different condition. And when other object reference this object with `DateTime`, they need to be initialized when variable define if we don't want to see the warning. In nim, variable can be defiend as:

Re: init DateTime is very annoying because we always need to initialize the DateTime object

2018-04-30 Thread mashingan
It's more like because `DateTime` is a reference type. Since a reference type has to be called by `new` first, it's default to nil .

Re: init DateTime is very annoying because we always need to initialize the DateTime object

2018-04-30 Thread GULPF
This happens because the default value for all types is binary 0, which is invalid for the `Month` type which starts at 1. Hopefully the compiler will be changed in the future so that enum/range types are instead initialized to their lowest value. Since `string` and `seq` will soon be lazily ini

init DateTime is very annoying because we always need to initialize the DateTime object

2018-04-30 Thread slangmgh
When I include the `DateTime` into the object, I cannot use the object freely because the compiler always complain that the `DateTime` field is not initialized. type User = object name: string age: int birthday: DateTime var u = User(nam