Re: Segfault while building on 64-bit Cygwin

2020-01-24 Thread John Cowan
Both Cygwin and MacOS crash in pretty much the same way.  By disabling the
JIT, I was able to get the Cygwin build to run to completion.  On MacOS
with --disable-jit, however, I am now getting an entirely new failure:

  CC   readline.lo
readline.c:432:7: warning: implicitly declaring library function 'strncmp'
with type 'int (const char *, const char *,
  unsigned long)' [-Wimplicit-function-declaration]
  if (strncmp (rl_get_keymap_name (rl_get_keymap ()), "vi", 2))
  ^
readline.c:432:7: note: include the header  or explicitly provide
a declaration for 'strncmp'
readline.c:432:16: warning: implicit declaration of function
'rl_get_keymap_name' is invalid in C99
  [-Wimplicit-function-declaration]
  if (strncmp (rl_get_keymap_name (rl_get_keymap ()), "vi", 2))
   ^
readline.c:432:16: warning: incompatible integer to pointer conversion
passing 'int' to parameter of type 'const char *'
  [-Wint-conversion]
  if (strncmp (rl_get_keymap_name (rl_get_keymap ()), "vi", 2))
   ^
3 warnings generated.
  CCLD guile-readline.la
Undefined symbols for architecture x86_64:
  "_rl_get_keymap_name", referenced from:
  _scm_init_readline in readline.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)

On Thu, Jan 23, 2020 at 3:35 PM Ludovic Courtès  wrote:

> Hi,
>
> John Cowan  skribis:
>
> > Thanks.  Unfortunately, the standard recipe for making core dumps on Mac
>
> This bug report is about Cygwin, not macOS, right?  :-)
>
> Ludo’.
>


Re: Fwd: Announcing the first stable release of guile-for-loops

2020-01-24 Thread Linus Björnstam
Yeah, when iterating through many different things at the same time it is 
extremely helpful. 

I would have loved syntax parse when writing the macros :) I read your for 
loops code in awe, at least until I saw how you "cheated" with set! :-P

My only chance of getting it into guile proper would be to 1. Make a SRFI and 
survive the SRFI process with my honour intact and 2. Code cleanup. Most of 
for/emit is OKish, but for/foldr needs to be beaten with a stick, burnt and 
rewritten. "bending hygiene" doesn't quite cover what I did to make it work. In 
the end I sort of kind of worked around it by making an API change, but it 
still stinks. Defining a new loop using for/foldr involves having to do a 
syntax->datum->syntax. No fun. I could check how racket does it, but given they 
can do syntax-local-introduce (which is specific to their "hygiene as sets of 
scopes") I suspect I am out of luck. 

Väl mött
  Linus Björnstam

On Fri, 24 Jan 2020, at 13:13, Stefan Israelsson Tampe wrote:
> 
> 
> -- Forwarded message -
> From: *Stefan Israelsson Tampe* 
> Date: Fri, Jan 24, 2020 at 12:42 PM
> Subject: Re: Announcing the first stable release of guile-for-loops
> To: Linus Björnstam 
> 
> 
> Would be cool to have those implemented in guile, that would make my 
> guile-syntax-parse a bit leaner
> 
> Regards
> Stefan
> 
> On Thu, Jan 23, 2020 at 3:03 PM Linus Björnstam 
>  wrote:
> > Hiya everybody!
> > 
> >  I have spent some time implementing efficient for loops for guile, and 
> > they are baked and ready to go. I have worked the last weeks at 
> > implementing generalized support for non-tail-recursive loops and am happy 
> > to announce for/foldr. It is a generic right fold, with support for 
> > delaying it's arguments as either thunks or promises. 
> > 
> >  The syntax is more or less the same as racket's loops, and they are 
> > generally compatible. The code generated is for almost all cases as fast as 
> > hand-rolled code. They are all expressed as left or right folds, and are as 
> > such (apart from for/list, but read about that in the documentation) free 
> > of mutation. They are all converted to named lets. 
> > 
> >  Some examples:
> > 
> >  (for/list ((a (in-range 1 6)))
> >  (* a a)) ;; => (1 4 9 16 25)
> > 
> >  (for*/list ((a (in-string "ab")) (b (in-range 1 3)))
> >  (list a b)) 
> >  ;; => ((#\a 1) (#\a 2) (#\b 1) (#\b 2))
> > 
> >  There are many more looping constructs, among others: 
> >  for/sum, for/vector, for/or, for/and, for/first, for/last and a 
> > side-effecting simple for.
> > 
> >  Here is a sieve of erathostenes:
> > 
> >  (define (erathostenes n)
> >  (define vec (make-vector n #t))
> >  (for/list ([i (in-range 2 n)] #:when (vector-ref vec i))
> >  (for ([j (in-range/incr (* 2 i) n i)])
> >  (vector-set! vec j #f))
> >  i))
> > 
> >  The code and documentation is available here: 
> > https://hg.sr.ht/~bjoli/guile-for-loops
> > 
> >  A web-friendly documentation can be found here: 
> > https://man.sr.ht/%7Ebjoli/for-loops-docs/for-loops.md 
> > 
> > 
> >  The thing I had been waiting for is right fold. That allows us to write 
> > loops like guile's map: non-tail recursive:
> >  (for/foldr ((identity '())) ((a (in-list '(1 2 3
> >  (cons (* a a) identity))
> > 
> >  becomes equivalent to:
> > 
> >  (let loop ((random-identifier '(1 2 3)))
> >  (if (null? random-identifier)
> >  '()
> >  (let ((a (car random-identifier)))
> >  (cons (* a a) (loop (cdr random-identifier))
> > 
> >  Happy hacking
> >  Linus Björnstam
> >



Re: Announcing the first stable release of guile-for-loops

2020-01-24 Thread Nala Ginrut
+1

On Fri, Jan 24, 2020, 20:13 Stefan Israelsson Tampe 
wrote:

>
>
> -- Forwarded message -
> From: Stefan Israelsson Tampe 
> Date: Fri, Jan 24, 2020 at 12:42 PM
> Subject: Re: Announcing the first stable release of guile-for-loops
> To: Linus Björnstam 
>
>
> Would be cool to have those implemented in guile, that would make my
> guile-syntax-parse a bit leaner
>
> Regards
> Stefan
>
> On Thu, Jan 23, 2020 at 3:03 PM Linus Björnstam <
> linus.bjorns...@veryfast.biz> wrote:
>
>> Hiya everybody!
>>
>> I have spent some time implementing efficient for loops for guile, and
>> they are baked and ready to go. I have worked the last weeks at
>> implementing generalized support for non-tail-recursive loops and am happy
>> to announce for/foldr. It is a generic right fold, with support for
>> delaying it's arguments as either thunks or promises.
>>
>> The syntax is more or less the same as racket's loops, and they are
>> generally compatible. The code generated is for almost all cases as fast as
>> hand-rolled code. They are all expressed as left or right folds, and are as
>> such (apart from for/list, but read about that in the documentation) free
>> of mutation. They are all converted to named lets.
>>
>> Some examples:
>>
>> (for/list ((a (in-range 1 6)))
>>   (* a a)) ;; => (1 4 9 16 25)
>>
>> (for*/list ((a (in-string "ab")) (b (in-range 1 3)))
>>   (list a b))
>> ;; => ((#\a 1) (#\a 2) (#\b 1) (#\b 2))
>>
>> There are many more looping constructs, among others:
>> for/sum, for/vector, for/or, for/and, for/first, for/last and a
>> side-effecting simple for.
>>
>> Here is a sieve of erathostenes:
>>
>> (define (erathostenes n)
>>   (define vec (make-vector n #t))
>>   (for/list ([i (in-range 2 n)] #:when (vector-ref vec i))
>> (for ([j (in-range/incr (* 2 i) n i)])
>>   (vector-set! vec j #f))
>> i))
>>
>> The code and documentation is available here:
>> https://hg.sr.ht/~bjoli/guile-for-loops
>>
>> A web-friendly documentation can be found here:
>> https://man.sr.ht/%7Ebjoli/for-loops-docs/for-loops.md
>>
>> The thing I had been waiting for is right fold. That allows us to write
>> loops like guile's map: non-tail recursive:
>> (for/foldr ((identity '())) ((a (in-list '(1 2 3
>>   (cons (* a a) identity))
>>
>> becomes equivalent to:
>>
>> (let loop ((random-identifier '(1 2 3)))
>>   (if (null? random-identifier)
>>   '()
>>   (let ((a (car random-identifier)))
>> (cons (* a a) (loop (cdr random-identifier))
>>
>> Happy hacking
>> Linus Björnstam
>>
>>


RE: bug#39118: Segfault while building on 64-bit Cygwin

2020-01-24 Thread dsmich
Pretty sure that the missing readline symbol is because the macos
readline is being used/found instead of GNU readline.

-Dale

-From: "John Cowan" 
To: "Ludovic Courtès"
Cc: 39...@debbugs.gnu.org, guile-devel@gnu.org
Sent: Friday January 24 2020 9:36:59AM
Subject: bug#39118: Segfault while building on 64-bit Cygwin

Both Cygwin and MacOS crash in pretty much the same way. By disabling
the JIT, I was able to get the Cygwin build to run to completion. On
MacOS with --disable-jit, however, I am now getting an entirely new
failure:
 CC readline.lo
readline.c:432:7: warning: implicitly declaring library function
'strncmp' with type 'int (const char *, const char *,
 unsigned long)' [-Wimplicit-function-declaration]
 if (strncmp (rl_get_keymap_name (rl_get_keymap ()), "vi", 2))
 ^
readline.c:432:7: note: include the header  or explicitly provide a
declaration for 'strncmp'
readline.c:432:16: warning: implicit declaration of function
'rl_get_keymap_name' is invalid in C99
 [-Wimplicit-function-declaration]
 if (strncmp (rl_get_keymap_name (rl_get_keymap ()), "vi", 2))
 ^
readline.c:432:16: warning: incompatible integer to pointer conversion
passing 'int' to parameter of type 'const char *'
 [-Wint-conversion]
 if (strncmp (rl_get_keymap_name (rl_get_keymap ()), "vi", 2))
 ^
3 warnings generated.
 CCLD guile-readline.la [1]
Undefined symbols for architecture x86_64:
 "_rl_get_keymap_name", referenced from:
 _scm_init_readline in readline.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)

On Thu, Jan 23, 2020 at 3:35 PM Ludovic Courtès  wrote:
Hi,

 John Cowan  skribis:

 > Thanks. Unfortunately, the standard recipe for making core dumps on
Mac

 This bug report is about Cygwin, not macOS, right? :-)

 Ludo’.
  

Links:
--
[1] http://guile-readline.la
[2] mailto:l...@gnu.org
[3] mailto:co...@ccil.org