Menu

Commit [r13054]  Maximize  Restore  History

.NET: 4GL's implicit conversions, display widths, and a README

4GL allows LET lv_char = lv_int and converts on the way; C# does not. The
generator already resolves this at compile time, emitting an explicit
conversion only where the declared types differ - LET b = a between two
INTEGERs still emits a plain assignment. This adds the conversions it
emits: AsChar, AsString, AsInt, AsSmallInt, AsBigInt, AsDecimal, AsFloat,
AsSmallFloat, AsBool, AsDate, AsDateTime, AsMonthSpan and AsTimeSpan.

They are hand-written rather than System.Convert, which is wrong in the
three places that matter and has a test spelling it out: Convert rounds
7.9 to 8 where 4GL truncates to 7, turns NULL into 0 where 4GL keeps
NULL, and throws on "abc" where 4GL yields NULL.

DISPLAY now passes each value's width, not just a DECIMAL's precision.
4GL prints an INTEGER in 11 columns, a SMALLINT in 6, a FLOAT in 14 - and
a NULL still occupies its field, which a boxed null cannot know on its
own. CHAR is deliberately excluded: it is already padded at assignment,
and widening it again would defeat CLIPPED.

A fifth end-to-end program, convert.4gl, covers thirteen cross-type
assignments including truncation of negatives and NULL propagation. All
four end-to-end programs and the other four probes pass.

Adds dotnet/README.md.

mikeaubury 2026-09-02

added /aubit4glsrc/trunk/dotnet/README.md
added /aubit4glsrc/trunk/dotnet/fidelity/endtoend/convert.4gl
changed /aubit4glsrc/trunk/dotnet/src/Aubit4GL.Runtime/FglSession.cs
changed /aubit4glsrc/trunk/dotnet/src/Aubit4GL.Runtime/Types/FglBuiltins.cs
added /aubit4glsrc/trunk/dotnet/src/Aubit4GL.Runtime/Types/FglConvert.cs
added /aubit4glsrc/trunk/dotnet/tests/Aubit4GL.Runtime.Tests/ConversionTests.cs
changed /aubit4glsrc/trunk/lib/liblex/lex_cs/compile_cs.c
/aubit4glsrc/trunk/dotnet/README.md Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/dotnet/fidelity/endtoend/convert.4gl Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/dotnet/src/Aubit4GL.Runtime/FglSession.cs Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/dotnet/src/Aubit4GL.Runtime/Types/FglBuiltins.cs Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/dotnet/src/Aubit4GL.Runtime/Types/FglConvert.cs Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/dotnet/tests/Aubit4GL.Runtime.Tests/ConversionTests.cs Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/lib/liblex/lex_cs/compile_cs.c Diff Switch to side-by-side view
Loading...