Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullable support #562

Open
arakov opened this issue Jan 20, 2023 · 1 comment
Open

Nullable support #562

arakov opened this issue Jan 20, 2023 · 1 comment
Labels
Feature request New language feature
Milestone

Comments

@arakov
Copy link
Member

arakov commented Jan 20, 2023

Is your feature request related to a problem? Please describe.
Compiler should warn if the operation with nil is possible. Nil-safe code should be used instead. Only implicitly nullable types
should allow operation where the target can be nil

Describe the solution you'd like
The type declaration should have a special attribute ?

import extensions;

singleton Tester
{
   test(int? prm)
   {
      ^ prm.hasValue ? (prm.Value) : 0
   }
}

public program()
{
   var t := Tester;

   console.printLine("Tester.test(2)=",Tester.test(2));
   console.printLine("t.test(3)=",t.test(3));

   console.printLine("Tester.test(nil)=",Tester.test(nil));
   console.printLine("t.test(nil)=",t.test(nil));
}   

The nullable structures are special case - they are in fact a reference type

Open issues:

  • boxing to Nullable?
  • support nullable reference (when option is on, warning on unsafe operation)
  • nullable : int? == int? -> return bool?
  • nullable : int? + int? -> return int? (if both nil -> the result is nil)
  • nillable argument list
@arakov arakov added the Feature request New language feature label Jan 20, 2023
@arakov arakov added this to the ELENA 6.0 milestone Jan 20, 2023
@arakov
Copy link
Member Author

arakov commented Jan 24, 2024

  • Nullable.ValueOrDefault to returen value or default value
  • nullable template argument
  • nullable closure argument

arakov added a commit that referenced this issue Jan 24, 2024
arakov added a commit that referenced this issue Jan 24, 2024
@arakov arakov mentioned this issue Feb 10, 2024
1 task
arakov added a commit that referenced this issue Feb 10, 2024
* starting a new iteration - 19

* [FIXED]do not box the target for direct extension call

* [FIXED]resolving an extension without parameters

* working on #604

* house keeping : rolling back changes for tracing the error

* [FIXED]#604 - using byref handler for extensions

* [ADDED]optimization : looking ahead for operand expressions if byref handler can be used

* [IDE][FIXED]debugger : step inside a nested class / closure

* [FIXED]#624 - GC routine

* [ADDED]inplace default / conversion constructors
[ADDED]built-in variable default

* [DELETED]get rid of embeddable method attribute

* [ADDED]opcodes : xsave n, xsave offs, n

* simplify constant assigning

* [ADDED]inplace call of the conversion constructor

* [FIXED]ecv formatting: insert spaces into the first space; fix display with byte code

* [ADDED]pointer h := UnsafePointer.Empty; - embeddable constructor call

* [ADDED]#629 : Post increment/decrement operators

* refactoring script grammar

* refactoring script support

* refactoring scripts

* refactoring lscript

* [FIXED]script engine : bookmark resolving

* working on the script routines

* tracing

* [FIXED]in-place constructors

* working on default support

* working on in-place constructor call

* refactoring compiler code

* [FIXED]built-in variable default

* [FIXED]#630 - Nil reference cannot be assigned to struct

* fixing code

* house keeping

* working on script samples

* working on script samples

* working on script samples

* [FIXED]bytecode optimization

* [FIXED]#132 anagram sample

* [FIXED]#132 - anagram sample

* working on gui samples

* [ADDED]gui controls
[ADDED]elenasm for Linux

* [FIXED]#623 - Overriding property set accessor
[FIXED]#601 - bytecode optimization

* [ADDED]#629 - Read-only fields
[FIXED]#613 - bytecode optimization

* [FIXED]"this self" for an extension
[ADDED]system : Int8Number, UShortNumber

* [FIXED]#508 - working on multi-value assigning
[FIXED]#86 - primitive operations : int + long

* [ADDED]meta command #load, #clear
[ADDED]#563:Extended statement templates

* fixing warnings for the standard library

* [FIXED]syntax for multi value method

* refactoring rosetta code samples

* refactoring code to support nullable types

* #562 - implementing nullable return type
@arakov arakov mentioned this issue Feb 10, 2024
1 task
arakov added a commit that referenced this issue Jun 5, 2024
arakov added a commit that referenced this issue Jun 10, 2024
arakov added a commit that referenced this issue Jun 12, 2024
* #562 : refactoring before adding support for nullable
* #562 : assigning nillable to struct
* #661 : try block with ret expression must have an extra block where the previous catch block is restored and jumped to the end
* MT : fixing an issue with infinite GC wait
* [FIXED] exception handling in a thread
* [FIXED] event handler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request New language feature
Projects
None yet
Development

No branches or pull requests

1 participant