May 10, 2007
Is it legal to throw an exception from a signal handler?  This
seems risky (though appealing).


Sean
May 10, 2007
Bill Baxter wrote:
> Frits van Bommel wrote:
>> Bill Baxter wrote:
>>> Silverling wrote:
>>  >> Bill Baxter wrote:
>>>>> Storage format?
>>>> Currently Type[row][col].
>>>
>>> Got it.  You may be better off with Type[row*col].  Type[row][col] is an array of col pointers to 1D arrays of rows, rather than densely packed memory.
>>
>> No, it's definitely densely packed memory. Static arrays always put their elements directly where you put the array itself, "inline".
>>
>> Only dynamic (Type[]) and associative (Type[Type2]) arrays use "hidden" pointers.
> 
> Ok, but he said it was going to be resizeable.  Does that change your answer?

Hmm... Right. I don't see how he could do that for non-square matrices without allocating a new matrix; if general resizing is implemented, he must've used a different storage format (not Type[row*col] either, but Type[] with length (row*col) would work). Maybe he was just inaccurate with in his answer...
May 10, 2007
Frits van Bommel Wrote:

> Bill Baxter wrote:
> > Frits van Bommel wrote:
> >> Bill Baxter wrote:
> >>> Silverling wrote:
> >>  >> Bill Baxter wrote:
> >>>>> Storage format?
> >>>> Currently Type[row][col].
> >>>
> >>> Got it.  You may be better off with Type[row*col].  Type[row][col] is an array of col pointers to 1D arrays of rows, rather than densely packed memory.
> >>
> >> No, it's definitely densely packed memory. Static arrays always put their elements directly where you put the array itself, "inline".
> >>
> >> Only dynamic (Type[]) and associative (Type[Type2]) arrays use "hidden" pointers.
> > 
> > Ok, but he said it was going to be resizeable.  Does that change your answer?
> 
> Hmm... Right. I don't see how he could do that for non-square matrices without allocating a new matrix; if general resizing is implemented, he must've used a different storage format (not Type[row*col] either, but Type[] with length (row*col) would work). Maybe he was just inaccurate with in his answer...


With resizeable arrays, I init a new array like this

Type[][] data=new Type[][](rows, cols);

Since array resizings only occur in multiplications and transposes of matrices of non-square matrices, I believe it to be doable.
May 10, 2007
Sean Kelly wrote:
> Is it legal to throw an exception from a signal handler?  This
> seems risky (though appealing).
> 
> 
> Sean

It seems to work, OTOH I never catch it so it might be causing problems that I'm not noticing. Really the only reason I have it is so that my DIY stack trace works on seg-vs

// at the top of *every* function
scope(failure) writef("backtrace@"__FILE__~itoa!(__LINE__)~\n);
May 10, 2007
"Silverling" <este_aqui_@hotmail.com.remove.underscores> wrote in message news:f1sqc4$2jsj$1@digitalmars.com...
>I am programming a Matrix class to be used like a primitive type (overloaded operators, identity, transpose, the whole shebang) and one of the constructors _may_ cause an Access Violation (or Segmentation Fault, if you prefer the old Linux SIGSEG) if the class's user is foolish. Is there a way to catch this errors?

void main()
{
    try
        *cast(byte*)null = 0;
    catch(Exception e)
        writefln("I caught : ", e);
}

I hope this works on Linux too.  I'm not sure if it will.


1 2
Next ›   Last »