Meta:
import std.typecons;
Nullable!(string[]) func(string[] zz) pure nothrow
{
return Nullable!(string[])();
}
void main()
{
//AssertError thrown for trying to get
//a value that is null. Might as well
//return null at this point
auto x = func(["test"])
On Tuesday, 19 November 2013 at 19:31:41 UTC, bearophile wrote:
The clean design is to use std.typecons.Nullable:
Nullable!(string[]) func(string[] zz) {
I have found that Nullable is pretty much useless for this type
of usage, because it aliases itself to the underlying value, and
then any
Dicebot:
I don't want to argue this in details right now but I think
that simply banning null references as valid arrays in program
as a whole via contracts is better approach than adding extra
level of indirection via Nullable ;)
Nullable is a struct, it doesn't introduce a new leavel of
i
On Tuesday, 19 November 2013 at 19:15:10 UTC, seany wrote:
(so i want liek a C style fopen -like function, that , although
called with the syntax: file *f = fopen(balh, "bla"); can set f
to be false)
I think you have a misunderstanding here. C does not allow you to
return "false." Instead C s
On Tuesday, 19 November 2013 at 19:31:41 UTC, bearophile wrote:
A Nullable in usually efficient enough (there is even an
alternative Nullable that doesn't increase the data size), it
makes typing stronger, and it should become more common in
system languages (and indeed it's commonly used in Ru
seany:
I have a function FUNC, it takes a string array, and does
something with it, and retruns the same. Implemented based on a
previous thread, here is what i have
string[] FUNC (ref string[] ZZ)
I told you to use ref if you want to modify in-place the length
of the array, as in the exap
On 11/19/2013 11:15 AM, seany wrote:
> Consider this:
>
> I have a function FUNC, it takes a string array, and does something with
> it, and retruns the same. Implemented based on a previous thread, here
> is what i have
>
> string[] FUNC (ref string[] ZZ)
> {
> /*
> do something
> */
> }
>
> and
On Tuesday, 19 November 2013 at 19:15:10 UTC, seany wrote:
Now, I want, should the function be not successful in doing
what it intends to do, to return a boolean value of false, to
ZZ, un fortunately ZZ is already a string[] (so i want liek a C
style fopen -like function, that , although called
On Tuesday, 19 November 2013 at 19:15:10 UTC, seany wrote:
Consider this:
I have a function FUNC, it takes a string array, and does
something with it, and retruns the same. Implemented based on a
previous thread, here is what i have
string[] FUNC (ref string[] ZZ)
{
/*
do something
*/
}
and
Uh I forgot to mention that it should do this without global
variables, and without try / catch
10 matches
Mail list logo