On Thu, 5 Nov 2015 07:36:53 +0100 Ondrej Pokorny <laza...@kluug.net> wrote:
> On 03.11.2015 20:26, Mattias Gaertner wrote: > > Of course there are some hard coded defaults in codetools. For example > > "i:=3" can be any integer type. > > It would be nice if integer constants were able to resolve their type: > > 3 -> ShortInt > 180 -> SmallInt > etc etc. > > This would be good for: > var > b: Byte; > begin > i := b + 500; > end; The 500 is for codetools an xtConstOrdInteger. It is FindExprTypeAsString that returns 'Integer' for xtConstOrdInteger. > this code creates "i: Byte;" in r50230. > I still think it is better than the behavior before r50230 that created > "i: Integer;" for: > > var > b: Byte; > begin > i := b + 1; > end; > > Because adding a constant out of the bounds of one operand is much less > common than within its bounds (IMO). Fine with me. > > But what type should "i:=3.0" create? Single, Double, Extended, > > glFloat? > Yes, whatever: single, double, extended, glFloat - maybe create an IDE > option for default integer/float/string/boolean types? The user then can > decide what precision he wants to use by default. Do you think it is > possible? Yes, why not? > The integer predefined setting should be preferred to the resolved type > in case there is no well-defined variable. E.g.: > i := 10 + 5; > Should create the user-defined default integer type ("i: integer" by > default) and not "i: Byte". Yes. Mattias -- _______________________________________________ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus