[racket-users] Raising multiple exceptions at once

2017-07-03 Thread reilithion
Hi,

I have a program that uses multiple threads and may have several exceptions 
happen more-or-less at once. I'd like to be able to raise them all together and 
have all of them printed to stderr, including stack traces.

I first tried just throwing them in a list and raising the list, but of course 
that doesn't come out very pretty (only one thread failed in this example):

uncaught exception: (list (exn:fail:task-failed "I failed.\n" 
# ...))

Next, I thought I'd try looping through the exceptions and using exn->string. 
But it seems this function doesn't give me stack traces or any kind of source 
location information.

It occurred to me to try to use the same mechanism that the REPL does, but I 
don't know anything about it, and I found the documentation on prompts and 
aborts to be a bit confusing. I didn't grok how the REPL used them to pull off 
its magic trick. What's the right way to go about this?

Thanks,
Lucas

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Defining things in two phases at once

2017-07-03 Thread 'William J. Bowman' via Racket Users
You can use 'module' to define a sub module in the same file, then import the 
function at both phases as you would from another file. See the docs for the 
module form. E.g.

#lang racket

(module racket A
 (provide foo)
 ...
)

(require (submod 'A) (for-syntax (submod 'A))

-- 
Sent from my phoneamajig

> On Jul 4, 2017, at 00:32, Sam Waxman  wrote:
> 
> Hello,
> 
> I have a function, foo, that I define in a file, and then use later on in 
> that file in multiple other functions. In some of the functions, I need foo 
> at phase 0. In others, I need it at phase 1.
> 
> Is there a way to define foo in both phases at once, or do you need to copy 
> and paste the definition, once with define and once with define-for-syntax?
> 
> I could of course define it in another file and export it in both phases, but 
> it truthfully belongs in the same file as the other things I'm using it for.
> 
> Thanks in advance!
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Defining things in two phases at once

2017-07-03 Thread Sam Waxman
Hello,

I have a function, foo, that I define in a file, and then use later on in that 
file in multiple other functions. In some of the functions, I need foo at phase 
0. In others, I need it at phase 1.

Is there a way to define foo in both phases at once, or do you need to copy and 
paste the definition, once with define and once with define-for-syntax?

I could of course define it in another file and export it in both phases, but 
it truthfully belongs in the same file as the other things I'm using it for.

Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Error when codesigning Racket created executable - codesign_allocate: file not in an order that can be processed

2017-07-03 Thread Seamus Brady
On Monday, 3 July 2017 15:18:07 UTC+1, Matthew Flatt  wrote:
> At Mon, 3 Jul 2017 08:15:38 -0600, Matthew Flatt wrote:
> > to make progress for now, you can
> > change
> > 
> >  collects/compiler/private/mach-o.rkt
> > 
> > and replace the call on line 164 to `detect-linkedit-padding` with the
> > constant 12 --- since 12 seems to be the right number for the v6.9
> > build, but `detect-linkedit-padding` thinks it's 8.
> 
> Make that 4 instead of 12 if you're using `raco exe --gui`.

Thank you Matthew and Norman for taking the time to reply. I got a bit further 
than Norman :)

The trick from Matthew did the trick and that Racket based app gets signed and 
passes all the local GateKeeper checks :) Great stuff.  This means that I get 
create a commercial grade application using Racket - I am delighted. Thank you, 
thank you.

As some extra feedback that may be useful to other readers, I also had to edit 
the app slightly to conform to Apples latest app guidelines:

https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html

I needed to add  Resources folder and an Info.plist with the correct 
CFBundleIdentifier set for the Racket Framework:


http://www.apple.com/DTDs/PropertyList-1.0.dtd";>


CFBundleDevelopmentRegion
English
CFBundleExecutable
Racket
CFBundleIdentifier
org.racket-lang.Racket
CFBundleIconFile
Starter
CFBundleInfoDictionaryVersion
6.0
CFBundlePackageType
APPL
CFBundleSignature
MrSt
CFBundleVersion
6.9
CFBundleShortVersionString
6.9
NSPrincipalClass
NSApplicationMain
NSHighResolutionCapable

NSSupportsAutomaticGraphicsSwitching




Then I updated the framework folders using the bash script below so that they 
conform to the new folder structure as outlined in the Apple docs:

cd ..app/Contents/Frameworks/Racket.framework/Versions/
ln -s ./6.9_3m Current
cd ./.app/Contents/Frameworks/Racket.framework/
ln -s ./Versions/Current/Racket Racket
ln -s ./Versions/Current/Resources Resources

Then I signed the app using the codesign utility as outlined below:

https://successfulsoftware.net/2012/08/30/how-to-sign-your-mac-os-x-app-for-gatekeeper/

I hope that helps. Again, many thanks. I am very grateful to get this working. 
I would have lost weeks ot work otherwise!

Regards

Seamus

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: beating java (speed)

2017-07-03 Thread Jens Axel Søgaard
2017-07-03 18:40 GMT+02:00 George Neuner :

> On Sat, 1 Jul 2017 17:14:01 +0200, Jens Axel Søgaard
>  wrote:
>
> >Hi Billy
> >
> >Just curious. How long does the simple solution take:
> >
> >#lang racket/base
> >(require math/number-theory)
> >
> >(define (f n)
> >  (for/sum ([x (in-range 1 (+ n 1))]
> >#:when (= (length (divisors x)) 8))
> >   1))
> >
> >(f 10e6)
> >
> >/Jens Axel
>
> I think you mean "1e6" (1 million) per the Euler problem.
>
> Using Racket 6.9 on Win7, simple (1e6) takes ~16.4 seconds on my
> ancient 5yo i7-3770.  Billy's unsafe version takes ~4.2 seconds.
>
>
That's better than expected!

/Jens Axel

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: beating java (speed)

2017-07-03 Thread George Neuner
On Sat, 1 Jul 2017 17:14:01 +0200, Jens Axel Søgaard
 wrote:

>Hi Billy
>
>Just curious. How long does the simple solution take:
>
>#lang racket/base
>(require math/number-theory)
>
>(define (f n)
>  (for/sum ([x (in-range 1 (+ n 1))]
>#:when (= (length (divisors x)) 8))
>   1))
>
>(f 10e6)
>
>/Jens Axel

I think you mean "1e6" (1 million) per the Euler problem.

Using Racket 6.9 on Win7, simple (1e6) takes ~16.4 seconds on my
ancient 5yo i7-3770.  Billy's unsafe version takes ~4.2 seconds.

George

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: how to get full tracebacks in DrRacket?

2017-07-03 Thread Vincent St-Amour
On Sat, 01 Jul 2017 11:28:31 -0500,
Zelphir Kaltstahl wrote:
> 
> On Friday, June 30, 2017 at 5:10:44 PM UTC+2, Matthew Butterick wrote:
> > Is there a way to configure DrRacket so that it always prints the same 
> > full-length tracebacks that are visible on the command line? Here's an 
> > example of the same module run in both places. 
> 
> On command line I usually don't get a full trace unless I invoke with:
> 
> ~~~
> racket -l errortrace -t 
> ~~~
> 
> Does the option in DrRacket do this internally?

Yes. DrRacket's "debugging" option is roughly equivalent to this.

Vincent

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: beating java (speed)

2017-07-03 Thread George Neuner
On Sat, 1 Jul 2017 07:05:43 -0700 (PDT), "'Shakin Billy' via Racket
Users"  wrote:

>(compilation)
>i'm not sure this will speed things up since i don't measure the
>time using cli tools but built-in tools which run after the
>jit-compilation took place, but i will give it a try.

The JIT compiler works incrementally as functions are 1st executed.
You need to touch (execute) all the functions prior to timing, or else
part of the time will be for compilation.

https://docs.racket-lang.org/guide/performance.html?q=jit#%28tech._jit%29

George

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Error when codesigning Racket created executable - codesign_allocate: file not in an order that can be processed

2017-07-03 Thread Matthew Flatt
At Mon, 3 Jul 2017 08:15:38 -0600, Matthew Flatt wrote:
> to make progress for now, you can
> change
> 
>  collects/compiler/private/mach-o.rkt
> 
> and replace the call on line 164 to `detect-linkedit-padding` with the
> constant 12 --- since 12 seems to be the right number for the v6.9
> build, but `detect-linkedit-padding` thinks it's 8.

Make that 4 instead of 12 if you're using `raco exe --gui`.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Error when codesigning Racket created executable - codesign_allocate: file not in an order that can be processed

2017-07-03 Thread Matthew Flatt
It looks like there's a problem with the part of `raco exe` that
removes the signature from the starting executable as it creates a new
one.

Specifically, it looks like `raco exe` fails to detect how much padding
was added to the original `__LINKEDIT` segment to add a code signature,
which is necessary for `raco exe` to remove that signature.

I'll try to fix that problem, but to make progress for now, you can
change

 collects/compiler/private/mach-o.rkt

and replace the call on line 164 to `detect-linkedit-padding` with the
constant 12 --- since 12 seems to be the right number for the v6.9
build, but `detect-linkedit-padding` thinks it's 8.

At Sun, 2 Jul 2017 14:57:29 -0700 (PDT), Seamus Brady wrote:
> Hi guys
> 
> I have a Racket based executable that I created using race exe / raco 
> distribute on macOS.
> I am trying to code sign it now so it passes through the macOS GateKeeper.
> 
> I had to add a few symlinks and edit the Info.plist to get the Racket 
> framework signed. That worked fine. But when I try to sign the actual main 
> executable in the app and the app itself, I am getting the error below:
> 
> "codesign_allocate: file not in an order that can be processed (link edit 
> information does not fill the __LINKEDIT segment)"
> 
> As a result the app gets rejected by the spctl assess check.
> 
> I cannot find any bug reports or Stackoverflow issues about Racket binaries 
> and codesigning on macOS but there seems to be similar problems with other 
> open sources binaries (such as binaries produced by PyInstaller).  The 
> problem 
> is a known one.
> 
> I was hoping that someone could provide some advice if anyone has seen 
> similar 
> problems.
> 
> Thanks in advance
> 
> Seamus
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Error when codesigning Racket created executable - codesign_allocate: file not in an order that can be processed

2017-07-03 Thread Norman Gray


Seamus, hello.

On 2 Jul 2017, at 22:57, Seamus Brady wrote:

I cannot find any bug reports or Stackoverflow issues about Racket 
binaries and codesigning on macOS but there seems to be similar 
problems with other open sources binaries (such as binaries produced 
by PyInstaller).  The problem is a known one.


I was hoping that someone could provide some advice if anyone has seen 
similar problems.


I'm not sure if it's exactly the same problem, but I attempted something 
similar a few years ago [1], and concluded that it was infeasible, then. 
 It seems that signing involves editing the OS X binary, and that is 
hard to do after linking.


Apologies if you've already found [1] on stackoverflow -- I mention it 
here since the post has a title that isn't obviously about code-signing.


Best wishes,

Norman


[1] 
https://stackoverflow.com/questions/4022495/how-can-i-add-sections-to-an-existing-os-x-executable


--
Norman Gray  :  https://nxg.me.uk
SUPA School of Physics and Astronomy, University of Glasgow, UK

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] un-prefix-out provide macro

2017-07-03 Thread Jens Axel Søgaard
Is filtered-out what you are looking for?

http://docs.racket-lang.org/reference/require.html?q=provide#%28form._%28%28lib._racket%2Fprovide..rkt%29._filtered-out%29%29

2017-07-03 9:59 GMT+02:00 Sam Waxman :

> Hello,
>
> I really need a provide macro with the following style
>
> (provide
>   (un-prefix-out "..Some-file/modulepath" number))
>
> Where the number will determine how many characters to delete from each
> identifier before exporting them.
>
> I.e., if we were to require racket as
>
> (require
>   (prefix-in rack- racket))
>
> so that all the racket functions are now prefixed by rack-, when I provide
> them, I want them to go back to what they used to be before I prefixed
> them, so I would write
>
> (provide
>   (un-prefix-out 5 racket)) (The macro should ideally recognize that I've
> already required racket, just like all-from-out does, so that it knows I'm
> exporting the things I've required.)
>
> (alternatively, instead of 5, it could be the identifier you want to
> un-prefix. Doesn't make much of a difference to me.)
>
>
>
> The root problem is that I have a number of files that I'd like to import
> for the sole purpose of exporting (I don't use their functions in the file
> I'm importing them.) These functions I'm importing, however, are named
> things that conflict with functions in racket, so they need to be prefixed
> in or I accidentally use them. I figured a nice solution would be to prefix
> them in, then take the prefix off when I provided them out. If there's a
> nicer way to deal with this, by all means let me know!
>
> I've been looking at https://docs.racket-lang.org/reference/stxtrans.html,
> but not making much headway.
>
> Thanks.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-- 
Jens Axel Søgaard

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] un-prefix-out provide macro

2017-07-03 Thread Sam Waxman
Hello,

I really need a provide macro with the following style

(provide
  (un-prefix-out "..Some-file/modulepath" number))

Where the number will determine how many characters to delete from each 
identifier before exporting them.

I.e., if we were to require racket as

(require
  (prefix-in rack- racket))

so that all the racket functions are now prefixed by rack-, when I provide 
them, I want them to go back to what they used to be before I prefixed them, so 
I would write

(provide
  (un-prefix-out 5 racket)) (The macro should ideally recognize that I've 
already required racket, just like all-from-out does, so that it knows I'm 
exporting the things I've required.)

(alternatively, instead of 5, it could be the identifier you want to un-prefix. 
Doesn't make much of a difference to me.)



The root problem is that I have a number of files that I'd like to import for 
the sole purpose of exporting (I don't use their functions in the file I'm 
importing them.) These functions I'm importing, however, are named things that 
conflict with functions in racket, so they need to be prefixed in or I 
accidentally use them. I figured a nice solution would be to prefix them in, 
then take the prefix off when I provided them out. If there's a nicer way to 
deal with this, by all means let me know!

I've been looking at https://docs.racket-lang.org/reference/stxtrans.html, but 
not making much headway.

Thanks.


-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.