On Wednesday, 27 August 2014 at 05:45:34 UTC, eles wrote:
While this may be true in this case, I think that, in general,
you cannot draw such a clear line between what's recoverable
and what's not. If you really want to push things to the
extreme, the sole unrecoverable error shall be
On 8/27/2014 2:39 PM, Vladimir Panteleev wrote:
On Monday, 25 August 2014 at 03:19:09 UTC, Mike Parker wrote:
I use Exception for recoverable errors and Error for those that aren't.
Sorry, you're right, that description of Exception/Error is correct. But
I don't think that SDL initialization
On Monday, 25 August 2014 at 03:19:09 UTC, Mike Parker wrote:
I use Exception for recoverable errors and Error for those that
aren't.
Sorry, you're right, that description of Exception/Error is
correct. But I don't think that SDL initialization is a
non-recoverable error. The program might
On Wednesday, 27 August 2014 at 05:45:34 UTC, eles wrote:
On Wednesday, 27 August 2014 at 05:39:59 UTC, Vladimir
Panteleev wrote:
On Monday, 25 August 2014 at 03:19:09 UTC, Mike Parker wrote:
failure and the SIGKILL.
(and SIGKILL just because you cannot catch it, otherwise you
could
On Wednesday, 27 August 2014 at 05:39:59 UTC, Vladimir Panteleev
wrote:
On Monday, 25 August 2014 at 03:19:09 UTC, Mike Parker wrote:
Sorry, you're right, that description of Exception/Error is
correct. But I don't think that SDL initialization is a
non-recoverable error. The program might
On 8/23/2014 7:19 PM, nikki wrote:
How would you write it?
```
// Put this somewhere you can import it into any module calling SDL
class SDLError : Error {
public this( string msg, string file = __FILE__, size_t line =
__LINE__ ) {
import std.string;
import std.conv;
On Monday, 25 August 2014 at 02:17:47 UTC, Mike Parker wrote:
// Put this somewhere you can import it into any module calling
Small modification for even terser error handling:
T sdlEnforce(T)(T result, string message = null)
{
if (!result)
throw new SdlException(SDL error:
~
On 8/25/2014 11:35 AM, Vladimir Panteleev wrote:
On Monday, 25 August 2014 at 02:17:47 UTC, Mike Parker wrote:
// Put this somewhere you can import it into any module calling
Small modification for even terser error handling:
T sdlEnforce(T)(T result, string message = null)
{
if (!result)
I am learning SDL by following the lazyfoo SDL2 tuorials, I am
alos new to D so I have a question:
I the lazyfoo tutorials there are many functions that have a bool
success whiich gets set at various places when something goes
wrong to be returned afterwards.
On Sat, 23 Aug 2014 10:19:58 +
nikki via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote:
don't use '==' to check for nulls. the right way is:
if (foo is null) {}
if (bar !is null) {}
'==' transforms to opEquals call (see 'operator overloading') and 'is'
not.
as for 'best
Oops well writing the above post made me realise what to look for
: http://dlang.org/errors.html
;)
On Saturday, 23 August 2014 at 10:29:04 UTC, ketmar via
Digitalmars-d-learn wrote:
On Sat, 23 Aug 2014 10:19:58 +
nikki via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
don't use '==' to check for nulls. the right way is:
if (foo is null) {}
if (bar !is null) {}
'=='
nikki:
How would you write it?
I don't know how much idiomatic this is, but you can start
cleaning up the code:
- Renaming the function with something more clear;
- using a D enumeration for the various constants.
- I have used a . before the module-level variables to denote
better they
ketmar:
don't use '==' to check for nulls. the right way is:
if (foo is null) {}
if (bar !is null) {}
'==' transforms to opEquals call (see 'operator overloading')
and 'is' not.
I use is and !is for class references and == != for pointers.
But now I think you are right, and in D it's
On Sat, 23 Aug 2014 10:53:03 +
bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com
wrote:
I use is and !is for class references and == != for pointers.
But now I think you are right, and in D it's better to always use
is and !is for both, to avoid present and future bugs
On Saturday, 23 August 2014 at 10:19:59 UTC, nikki wrote:
I am learning SDL by following the lazyfoo SDL2 tuorials, I am
alos new to D so I have a question:
I the lazyfoo tutorials there are many functions that have a
bool success whiich gets set at various places when something
goes wrong
On Saturday, 23 August 2014 at 10:33:02 UTC, nikki wrote:
A good to know! thanks.
I'd still be interrested to see the idiomatic D version of that
function, what would that depend on ?
Honestly, I wouldn't change it much. If it didn't throw
exceptions before, then it probably would have
On Saturday, 23 August 2014 at 11:07:23 UTC, ketmar via
Digitalmars-d-learn wrote:
and foo is null is nice to read. ;-)
Meh, looks like a guest from pascal or basic.
On Sat, 23 Aug 2014 15:10:22 +
Kagamin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com
wrote:
Meh, looks like a guest from pascal or basic.
so let's replace writeln() with %^#$#%^ then. this looks like a
function name for Real Hackers.
signature.asc
Description: PGP signature
On Saturday, 23 August 2014 at 11:07:23 UTC, ketmar via
Digitalmars-d-learn wrote:
and foo is null is nice to read. ;-)
function bool init
begin
rem Initialization flag
bool success assign true;
rem Initialize SDL
if execute SDL_Init SDL_INIT_VIDEO lt 0
begin
20 matches
Mail list logo