Re: [Bug-apl] cast from pointer to smaller type 'int'

2017-09-19 Thread Xiao-Yong Jin
Should have got back to you sooner, but static_cast is not allowed between 
pointer types and non-pointer types.

Thread_context.cc:73:11: error: static_cast from 'pthread_t' (aka 
'_opaque_pthread_t *') to 'int' is not allowed
   << static_cast(thread)
  ^~~~

I need reinterpret_cast here.  I cannot reinterpret_cast either, 
because of the difference in size.

> On Sep 11, 2017, at 3:01 PM, Juergen Sauermann 
>  wrote:
> 
> Hi Xiao-Yong,
> 
> I see. In this particular case the pthread_t is only used to identify a 
> thread and
> to distinguish it from other threads for debugging purposes. So as long as the
> compiler does not complain about the cast everything is fine. Cast to void * 
> instead of
> int would also be an option.
> 
> /// Jürgen
>  
> 
> On 09/11/2017 08:38 PM, Xiao-Yong Jin wrote:
>> I don't think there is a portable way of printing a variable of type 
>> pthread_t.  It could be a struct, depending on the implementation.  
>> static_cast is alright, but may not be useful in the future.
>> 
>> 
>>> On Sep 11, 2017, at 1:08 PM, Juergen Sauermann 
>>> 
>>>  wrote:
>>> 
>>> Hi Xiao-Yong,
>>> 
>>> thanks, maybe fixed in SVN 1011.
>>> Problem with that error is that the casted type is not a pointer, at least 
>>> on my machine.
>>> 
>>> /// Jürgen
>>> 
>>> 
>>> On 09/11/2017 06:55 PM, Xiao-Yong Jin wrote:
>>> 
 At revision 1010
 
 Thread_context.cc:72:65: error: cast from pointer to smaller type 'int' 
 loses information
out << "thread #" << setw(2) << N << ":" << setw(16)  << int(thread)
 
 
 
 
 
>> 
> 




[Bug-apl] Regex support

2017-09-19 Thread Elias Mårtenson
On several occasions, I have felt that built-in regex support in GNU APL
would be very helpful.

Implementing it should be rather simple, but I'd like to discuss how such
an API should look in order for it to be as useful as possible.

I was thinking of the following form:

  regex ⎕Regex string

The way I envision this to work, is to have the function return ⍬ if there
is no match, or a string containing the match, if there is one:

*  'f..' ⎕Regex 'xzooy'*
┏⊖┓
┃0┃
┗━┛
*  'f..' ⎕Regex 'xfooy'*
'foo'

If the regex has subexpressions, those matches should be returned as
individual strings:

*  '([0-9]+)-([0-9]+)-([0-9]+) '⎕Regex '2017-01-02'*
┏→━━━┓
┃"2017" "01" "02"┃
┗∊━━━┛

This would be a very useful API, and reasonably easy to implement by simply
calling into the standard regcomp() call:
http://pubs.opengroup.org/onlinepubs/009695399/functions/regcomp.html

What do you think? Is this a reasonable way to implement it? Any
suggestions about alternative API's?

Regards,
Elias