Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » The problem with 'Null'
The problem with 'Null' [message #20446] Thu, 19 March 2009 08:04 Go to previous message
gridem is currently offline  gridem
Messages: 45
Registered: August 2008
Member
I found that Upp uses the following practice: instead of creating already prepared object it creates the object with default constructor and than fill the necessary members in later calls. But using such approach the programmer should distinguish between init and non init state. One of the possible solution: apply 'Null' to the fields and than check by using IsNull.

The simple types (int, long etc) and Value already have such posibility. String also can use this but using another functionality:
String::GetVoid()
return 'super' empty string that may be treated as 'Null'. The problem is that
IsNull(String())
and
IsNull(String::GetVoid())
return both true. This may be workarounded but it's not a good solution. But for the Vector<T> the workaround is more complex: the programmer should use One<Vector<T> >. The problem may occur in situation when function should return result or error. In the following example:
String LoadFile(...)

the solution exist: return String::GetVoid() on error. But what I can do when I must return Vector:
Vector<Templates> GetTemplateList()

Empty list denotes the there are no templates. But how can I return error without using terrible One<Vector<T> >?
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: In some cases CParser can be out of buffer
Next Topic: Possible bug/clarification only callback2 was changed for const Object*
Goto Forum:
  


Current Time: Wed May 15 11:43:58 CEST 2024

Total time taken to generate the page: 0.02456 seconds