Re: [racket-users] error when intalling racket 6.5 in solaris (a sparc machine)

2016-06-29 Thread WarGrey Gyoudmon Ju
Also, you may want '--disable-libffi'

On Thu, Jun 30, 2016 at 11:11 AM, Matthew Flatt  wrote:

> I'm not sure, but it's possible that a newer version of libtool is
> needed.
>
> Meanwhile, does dropping the `--enable-shared` flag help? (I recommend
> that in any case, unless you specifically need a libracket shared
> library.)
>
> At Wed, 29 Jun 2016 22:33:59 -0400, HP Wei wrote:
> > I replaced ‘-KPIC’ with ‘-fPIC’ in all instances in the files that you
> listed.
> >
> > Start from a new build/;  configure … ; make —>  still get the same
> error.
> >
> > Then after the above failure, I noticed:
> >libtool —config | grep pic_flag
> > pic_flag= “ -KPIC -DPIC”
> >   libtool —config | grep CC
> > CC=“cc”
> >
> > So, something is not right with these configuration variables.
> > I am not familiar with libtool.
> > And I tried to set
> > export CC=gcc
> > export pic_flag=“ -fPIC -DPIC”
> > These did not help.
> >
> > Any suggestions ?
> > hp
> >
> >
> > > On Jun 29, 2016, at 8:43 PM, George Neuner 
> wrote:
> > >
> > >
> > > On 6/29/2016 6:00 PM, hpwe...@gmail.com 
> wrote:
> > >> I downloaded racket 6.5 sources
> > >> to a Sun's Sparc machine running Solaris (SunOS 5.11)
> > >> gcc version = 4.8.1
> > >>
> > >> in the build directory, I did these two steps:
> > >> ../configure --prefix=/a/path --enable-shared
> > >> make
> > >>
> > >> --> It exited with the following error message:
> > >>
> > >> cd sgc; make ../libmzgc.la
> > >> make[7]: Entering ... build/racket/sgc'
> > >> libtool --mode=compile ... -o sgc.lo
> > >> mkdir .libs
> > >>   gcc -Wall ... -KPIC -DPIC -c .../sgc.c -o .libs/sgc.o
> > >> gcc: error: unrecognized command line option '-KPIC'
> > >> ...
> > >>
> > >> I tried to look for where the option '-KPIC' was located in
> > >> the Makefiles --> but I could not find it.
> > >>
> > >> Any idea what happened and how I can proceed ?
> > >>
> > >> thanks
> > >> HP
> > >
> > > Back in the 90's I worked with SunOS5/Solaris, but this is a new one
> for
> > me.   :-)
> > >
> > > A little searching turned up that -KPIC / -Kpic  tells the Sun C
> compiler to
> > produce position independent code - the case of the flag determines the
> > maximum size of the global offset table.The equivalent GCC flags are
> -fPIC
> > / -fpic ... you *might* be able to get away with fixing up the
> makefile(s), if
> > there are no other CC specific options.   Otherwise, you can try
> changing the
> > configuration files [below] in the sections pertaining to Solaris and/or
> > SunOS, and then run configure again to start over.
> > >
> > > A grep of the [full] 6.5 release sources found the  -KPIC option
> referenced
> > in the following files:
> > >
> > > racket-6.5\src\foreign\libffi\configure
> > > racket-6.5\src\foreign\libffi\m4\libtool.m4
> > > racket-6.5\src\lt\aclocal.m4
> > > racket-6.5\src\lt\configure
> > > racket-6.5\src\racket\gc\configure
> > > racket-6.5\src\racket\gc\doc\README.DGUX386
> > > racket-6.5\src\racket\gc\libtool.m4
> > >
> > >
> > > Obviously the Racket build maintainers will have to fix this at the
> > configuration level.
> > >
> > > Hope this helps,
> > > 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.
>
> --
> 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 intalling racket 6.5 in solaris (a sparc machine)

2016-06-29 Thread Matthew Flatt
I'm not sure, but it's possible that a newer version of libtool is
needed.

Meanwhile, does dropping the `--enable-shared` flag help? (I recommend
that in any case, unless you specifically need a libracket shared
library.)

At Wed, 29 Jun 2016 22:33:59 -0400, HP Wei wrote:
> I replaced ‘-KPIC’ with ‘-fPIC’ in all instances in the files that you listed.
> 
> Start from a new build/;  configure … ; make —>  still get the same error.
> 
> Then after the above failure, I noticed:
>libtool —config | grep pic_flag
> pic_flag= “ -KPIC -DPIC”
>   libtool —config | grep CC
> CC=“cc”
> 
> So, something is not right with these configuration variables.
> I am not familiar with libtool.
> And I tried to set 
> export CC=gcc
> export pic_flag=“ -fPIC -DPIC” 
> These did not help.
> 
> Any suggestions ?
> hp
> 
> 
> > On Jun 29, 2016, at 8:43 PM, George Neuner  wrote:
> > 
> > 
> > On 6/29/2016 6:00 PM, hpwe...@gmail.com  wrote:
> >> I downloaded racket 6.5 sources
> >> to a Sun's Sparc machine running Solaris (SunOS 5.11)
> >> gcc version = 4.8.1
> >> 
> >> in the build directory, I did these two steps: 
> >> ../configure --prefix=/a/path --enable-shared
> >> make
> >> 
> >> --> It exited with the following error message:
> >> 
> >> cd sgc; make ../libmzgc.la
> >> make[7]: Entering ... build/racket/sgc'
> >> libtool --mode=compile ... -o sgc.lo
> >> mkdir .libs
> >>   gcc -Wall ... -KPIC -DPIC -c .../sgc.c -o .libs/sgc.o
> >> gcc: error: unrecognized command line option '-KPIC'
> >> ...
> >> 
> >> I tried to look for where the option '-KPIC' was located in 
> >> the Makefiles --> but I could not find it.
> >> 
> >> Any idea what happened and how I can proceed ?
> >> 
> >> thanks
> >> HP
> > 
> > Back in the 90's I worked with SunOS5/Solaris, but this is a new one for 
> me.   :-)
> > 
> > A little searching turned up that -KPIC / -Kpic  tells the Sun C compiler 
> > to 
> produce position independent code - the case of the flag determines the 
> maximum size of the global offset table.The equivalent GCC flags are 
> -fPIC 
> / -fpic ... you *might* be able to get away with fixing up the makefile(s), 
> if 
> there are no other CC specific options.   Otherwise, you can try changing the 
> configuration files [below] in the sections pertaining to Solaris and/or 
> SunOS, and then run configure again to start over.   
> > 
> > A grep of the [full] 6.5 release sources found the  -KPIC option referenced 
> in the following files:
> > 
> > racket-6.5\src\foreign\libffi\configure
> > racket-6.5\src\foreign\libffi\m4\libtool.m4
> > racket-6.5\src\lt\aclocal.m4
> > racket-6.5\src\lt\configure
> > racket-6.5\src\racket\gc\configure
> > racket-6.5\src\racket\gc\doc\README.DGUX386
> > racket-6.5\src\racket\gc\libtool.m4
> > 
> > 
> > Obviously the Racket build maintainers will have to fix this at the 
> configuration level.
> > 
> > Hope this helps,
> > 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.

-- 
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 intalling racket 6.5 in solaris (a sparc machine)

2016-06-29 Thread HP Wei
I replaced ‘-KPIC’ with ‘-fPIC’ in all instances in the files that you listed.

Start from a new build/;  configure … ; make —>  still get the same error.

Then after the above failure, I noticed:
   libtool —config | grep pic_flag
pic_flag= “ -KPIC -DPIC”
  libtool —config | grep CC
CC=“cc”

So, something is not right with these configuration variables.
I am not familiar with libtool.
And I tried to set 
export CC=gcc
export pic_flag=“ -fPIC -DPIC” 
These did not help.

Any suggestions ?
hp


> On Jun 29, 2016, at 8:43 PM, George Neuner  wrote:
> 
> 
> On 6/29/2016 6:00 PM, hpwe...@gmail.com  wrote:
>> I downloaded racket 6.5 sources
>> to a Sun's Sparc machine running Solaris (SunOS 5.11)
>> gcc version = 4.8.1
>> 
>> in the build directory, I did these two steps: 
>> ../configure --prefix=/a/path --enable-shared
>> make
>> 
>> --> It exited with the following error message:
>> 
>> cd sgc; make ../libmzgc.la
>> make[7]: Entering ... build/racket/sgc'
>> libtool --mode=compile ... -o sgc.lo
>> mkdir .libs
>>   gcc -Wall ... -KPIC -DPIC -c .../sgc.c -o .libs/sgc.o
>> gcc: error: unrecognized command line option '-KPIC'
>> ...
>> 
>> I tried to look for where the option '-KPIC' was located in 
>> the Makefiles --> but I could not find it.
>> 
>> Any idea what happened and how I can proceed ?
>> 
>> thanks
>> HP
> 
> Back in the 90's I worked with SunOS5/Solaris, but this is a new one for me.  
>  :-)
> 
> A little searching turned up that -KPIC / -Kpic  tells the Sun C compiler to 
> produce position independent code - the case of the flag determines the 
> maximum size of the global offset table.The equivalent GCC flags are 
> -fPIC / -fpic ... you *might* be able to get away with fixing up the 
> makefile(s), if there are no other CC specific options.   Otherwise, you can 
> try changing the configuration files [below] in the sections pertaining to 
> Solaris and/or SunOS, and then run configure again to start over.   
> 
> A grep of the [full] 6.5 release sources found the  -KPIC option referenced 
> in the following files:
> 
> racket-6.5\src\foreign\libffi\configure
> racket-6.5\src\foreign\libffi\m4\libtool.m4
> racket-6.5\src\lt\aclocal.m4
> racket-6.5\src\lt\configure
> racket-6.5\src\racket\gc\configure
> racket-6.5\src\racket\gc\doc\README.DGUX386
> racket-6.5\src\racket\gc\libtool.m4
> 
> 
> Obviously the Racket build maintainers will have to fix this at the 
> configuration level.
> 
> Hope this helps,
> 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] Confused about the get-info function for #langs

2016-06-29 Thread Alexis King
First of all, +1 for this stuff being confusing. I’ve been implementing
a language lately that needs its own lexer, reader, runtime
configuration, etc., and while the Racket docs are usually very good,
this stuff is sprawled out across the guide, the reference, the docs for
syntax/module-reader, the docs for DrRacket, and other random places.
It’s really hard to get a good grasp on all the details.

My current understanding of get-info is that it...

  (1) ...was designed to be extensible with arbitrary keys.
  (2) ...isn’t actually used for all that much.

The only key I have implemented myself is 'color-lexer, which is used by
DrRacket to pick a lexer for the highlighter. The DrRacket docs[1] also
include a number of other properties that can be used to customize
things like the indenter and toolbar buttons, but my impression is that
all of the things get-info is used for are for tooling, not for
adjusting language semantics in any way.

Of course, syntax/module-reader also passes a third argument[2], which
allows syntax/module-reader to provide some of its own defaults while
still allowing the user to override the implementation for those keys
and have access to the defaults provided to the get-info function. This
seems a bit needlessly complicated at first, but I’m not sure if there’s
a better way to do it.

Now, my impression is that for the vast majority of #langs, the get-info
function will never depend upon the contents of the input port provided
to the factory function, and in fact, syntax/module-reader skips that
step entirely and always provides the same function. However, for
meta-languages, the ability to read what language follows is extremely
important, because it needs to delegate to the underlying language to
get the actual get-info implementation. I can’t imagine that would ever
be terribly useful for things that don’t do that sort of delegation
trickery, though, so the syntax/module-reader interface seems to make a
lot more sense for the vast majority of languages.

That’s all I got, though. If you find out something more definitive,
centralizing this information in the documentation would be much
appreciated!

[1]: http://docs.racket-lang.org/tools/adding-languages.html
[2]: 
http://docs.racket-lang.org/syntax/reader-helpers.html#%28mod-path._syntax%2Fmodule-reader%29

> On Jun 29, 2016, at 15:58, Alex Knauth  wrote:
> 
> I'm trying to rewrite `make-meta-reader` to hopefully make more sense.
> 
> A racket #lang language normally defines and provides a `get-info` function 
> in its reader module along with `read` and `read-syntax`. However, there 
> seems to be very little documentation about what this is supposed to do, and 
> there are different versions for bare #langs versus `syntax/module-reader` 
> versus `make-meta-reader` versus `read-language`.
> 
> Is there anyone who can explain what is allowed and what isn't for the 
> `get-info` function that a #lang is supposed to provide?
> 
> ;; 
> 
> The only documentation I could find was in the Source-Handling Configuration 
> part of the Creating Languages section of the Racket Guide, here:
> http://docs.racket-lang.org/guide/language-get-info.html
> 
> It gives this example
> 
>> (define (get-info in mod line col pos)
>>   (lambda (key default)
>> (case key
>>   [(color-lexer)
>>(dynamic-require 'syntax-color/default-lexer
>> 'default-lexer)]
>>   [else default])))
> 
> And this explanation
> 
>> The get-info function is called by read-language (which DrRacket calls) with 
>> the source input stream and location information, in case query results 
>> should depend on the content of the module after the language name (which is 
>> not the case for literal). The result of get-info is a function of two 
>> arguments.
> 
> So the `in` argument is the input stream, and the `line`, `col`, and `pos` 
> arguments specify positions of something (what?). 
> 
> What is the second argument, the `mod` argument?
> 
> At the top I mentioned I was trying to rewrite `make-meta-reader`, which 
> needs to return a valid `get-info` function as one of its 3 return values. As 
> it does that it needs to go to the module returned by the 
> `module-path-parser` argument and use the original `get-info` function from 
> there. It seems to be doing some pretty weird stuff, having a `get` helper 
> function which return 2 values, the second of which is a `next-mod` thing, 
> which it passes as the second argument to the original `get-info` function, 
> and then passes the result of that to the `convert-get-info` function.
> 
> I am thoroughly confused by all of this. Can someone explain how the 
> `get-info` function is supposed to work?
> 
> Alex Knauth

-- 
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.

Re: [racket-users] error when intalling racket 6.5 in solaris (a sparc machine)

2016-06-29 Thread George Neuner


On 6/29/2016 6:00 PM, hpwe...@gmail.com wrote:

I downloaded racket 6.5 sources
to a Sun's Sparc machine running Solaris (SunOS 5.11)
gcc version = 4.8.1

in the build directory, I did these two steps:
../configure --prefix=/a/path --enable-shared
make

--> It exited with the following error message:

cd sgc; make ../libmzgc.la
make[7]: Entering ... build/racket/sgc'
libtool --mode=compile ... -o sgc.lo
mkdir .libs
   gcc -Wall ... -KPIC -DPIC -c .../sgc.c -o .libs/sgc.o
gcc: error: unrecognized command line option '-KPIC'
...

I tried to look for where the option '-KPIC' was located in
the Makefiles --> but I could not find it.

Any idea what happened and how I can proceed ?

thanks
HP


Back in the 90's I worked with SunOS5/Solaris, but this is a new one for 
me. :-)


A little searching turned up that *-KPIC / -Kpic*  tells the Sun C 
compiler to produce position independent code - the case of the flag 
determines the maximum size of the global offset table. The equivalent 
GCC flags are *-fPIC / **-fpic* ... you *might* be able to get away with 
fixing up the makefile(s), if there are no other CC specific options.   
Otherwise, you can try changing the configuration files [below] in the 
sections pertaining to Solaris and/or SunOS, and then run configure 
again to start over.


A grep of the [full] 6.5 release sources found the  -KPIC option 
referenced in the following files:


racket-6.5\src\foreign\libffi\configure
racket-6.5\src\foreign\libffi\m4\libtool.m4
racket-6.5\src\lt\aclocal.m4
racket-6.5\src\lt\configure
racket-6.5\src\racket\gc\configure
racket-6.5\src\racket\gc\doc\README.DGUX386
racket-6.5\src\racket\gc\libtool.m4


Obviously the Racket build maintainers will have to fix this at the 
configuration level.


Hope this helps,
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.


[racket-users] TR/contract regression since 6.5 related to duplicated structure name?

2016-06-29 Thread 'John Clements' via Racket Users
I’m running into what look like some bugs in the interactions between typed and 
untyped code. Specifically, I’m getting errors that look like this:

ct-error: Message: Record-role: contract violation
  expected: Record?
  given: (Record "test-class" "masteru...@example.com" (Record 0 "Instructor" 
#t))
  in: the 1st argument of
  (-> Record? any)
  contract from: 
  /admiral-edu-server/admiral-edu-server/database/mysql/role.rkt
  blaming: /admiral-edu-server/admiral-edu-server/pages/roster.rkt
   (assuming the contract is correct)
  at: /admiral-edu-server/admiral-edu-server/database/mysql/role.rkt:42.9

I don’t see this error in 6.5. 

Notice that there are *two* different structures here named “Record”, imported 
from different TR module.

I haven’t yet tried to minimize this example, but it looks like a 
chaperone/contract/TR-ish thing. Before I try to whittle this down to a 
manageable size, are there known new bugs in types & contracts since 6.5?

ObResearch: I took a quick look at the bug database and at the github issues 
page and didn’t see anything that jumped out at me.

John



-- 
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] Confused about the get-info function for #langs

2016-06-29 Thread Alex Knauth
I'm trying to rewrite `make-meta-reader` to hopefully make more sense.

A racket #lang language normally defines and provides a `get-info` function in 
its reader module along with `read` and `read-syntax`. However, there seems to 
be very little documentation about what this is supposed to do, and there are 
different versions for bare #langs versus `syntax/module-reader` versus 
`make-meta-reader` versus `read-language`.

Is there anyone who can explain what is allowed and what isn't for the 
`get-info` function that a #lang is supposed to provide?

;; 

The only documentation I could find was in the Source-Handling Configuration 
part of the Creating Languages section of the Racket Guide, here:
http://docs.racket-lang.org/guide/language-get-info.html 


It gives this example

> (define (get-info in mod line col pos)
>   (lambda (key default)
> (case key
>   [(color-lexer)
>(dynamic-require 'syntax-color/default-lexer
> 'default-lexer)]
>   [else default])))


And this explanation

> The get-info function is called by read-language (which DrRacket calls) with 
> the source input stream and location information, in case query results 
> should depend on the content of the module after the language name (which is 
> not the case for literal). The result of get-info is a function of two 
> arguments.

So the `in` argument is the input stream, and the `line`, `col`, and `pos` 
arguments specify positions of something (what?). 

What is the second argument, the `mod` argument?

At the top I mentioned I was trying to rewrite `make-meta-reader`, which needs 
to return a valid `get-info` function as one of its 3 return values. As it does 
that it needs to go to the module returned by the `module-path-parser` argument 
and use the original `get-info` function from there. It seems to be doing some 
pretty weird stuff, having a `get` helper function which return 2 values, the 
second of which is a `next-mod` thing, which it passes as the second argument 
to the original `get-info` function, and then passes the result of that to the 
`convert-get-info` function.

I am thoroughly confused by all of this. Can someone explain how the `get-info` 
function is supposed to work?

Alex Knauth


-- 
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] error when intalling racket 6.5 in solaris (a sparc machine)

2016-06-29 Thread hpwei01
I downloaded racket 6.5 sources
to a Sun's Sparc machine running Solaris (SunOS 5.11)
gcc version = 4.8.1

in the build directory, I did these two steps: 
../configure --prefix=/a/path --enable-shared
make

--> It exited with the following error message:

cd sgc; make ../libmzgc.la
make[7]: Entering ... build/racket/sgc'
libtool --mode=compile ... -o sgc.lo
mkdir .libs
  gcc -Wall ... -KPIC -DPIC -c .../sgc.c -o .libs/sgc.o
gcc: error: unrecognized command line option '-KPIC'
...

I tried to look for where the option '-KPIC' was located in 
the Makefiles --> but I could not find it.

Any idea what happened and how I can proceed ?

thanks
HP

-- 
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] Require Transformers

2016-06-29 Thread Alexis King
Just for fun, if you want to be a little bit naughty, you can define
a custom #%top transformer that will make unbound identifiers that
are fully qualified automatically resolve to their imported values.
Just do a little bit of processing on the unbound identifiers:

  #lang racket

  (require (for-syntax racket/list
   racket/match
   racket/string
   syntax/parse))

  (define-syntax #%top
(syntax-parser
  [(_ . id:id)
   (define id-str (symbol->string (syntax-e #'id)))
   (define components (string-split id-str "/"))
   (match-define-values (mod-components (list mod-id-str))
(split-at-right components 1))
   (define mod-path (string-join mod-components "/"))
   (with-syntax ([mod-path-id (string->symbol mod-path)]
 [mod-id (datum->syntax #'id (string->symbol mod-id-str))])
 (syntax-local-introduce
  (syntax-local-lift-require
   (syntax-local-introduce #'mod-path-id)
   (syntax-local-introduce #'mod-id]))

Now you can do something like this:

  > (racket/base/list 1 2 3)
  '(1 2 3)

Unfortunately, this won’t work for macros because unbound identifiers
handled by #%top cannot resolve to a macro identifier (more
specifically, the #%app introduced puts the produced syntax in an
expression context). I’m not sure if there’s a way around that, and
the explicit use of some sort of require transformer is definitely
much nicer. Just a little bit fun to see how easy it is to do
something like this. ;)

> On Jun 29, 2016, at 6:05 AM, Shakna Israel  wrote:
> 
> I'm trying to introduce an implicit binding for require.
> 
> One of the features I love about Python, is the namespace binding.
> 
> import sys
> 
> sys.stdout.write("Sweet")
> 
> I know this can also be accomplished with require by specifying a prefix-in, 
> or a prefix-out with a local-require.
> 
> However, I want a require that does that for me.
> 
> (require racket/base)
> (racket/base:println "It works!")
> 
> Figuring the namespace mangling is simple enough.
> 
> However, for this to work, I think I need a require transformer, but I'm at a 
> loss. The only example I see can mess with the module path, but not the 
> symbols it exposes.
> 
> Any pointers?
> 
> -- 
> 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] Require Transformers

2016-06-29 Thread Matthias Felleisen

Now cam someone show me how to get Racket-style requiring in Python :-) 


> On Jun 29, 2016, at 9:35 AM, Jay McCarthy  wrote:
> 
> I think you want this:
> 
> #lang racket/base
> (require (for-syntax racket/base
> syntax/parse
> racket/require-transform
> racket/syntax))
> 
> (define-syntax ns-in
>  (make-require-transformer
>   (λ (stx)
> (syntax-parse stx
>   [(_ mp:id)
>(with-syntax ([mp: (format-id #'mp "~a:" #'mp)])
>  (expand-import
>   (syntax/loc stx
> (prefix-in mp: mp]
> 
> (module+ test
>  (require (ns-in racket/list))
>  racket/list:empty)
> 
> On Wed, Jun 29, 2016 at 9:05 AM, Shakna Israel  wrote:
>> I'm trying to introduce an implicit binding for require.
>> 
>> One of the features I love about Python, is the namespace binding.
>> 
>> import sys
>> 
>> sys.stdout.write("Sweet")
>> 
>> I know this can also be accomplished with require by specifying a prefix-in, 
>> or a prefix-out with a local-require.
>> 
>> However, I want a require that does that for me.
>> 
>> (require racket/base)
>> (racket/base:println "It works!")
>> 
>> Figuring the namespace mangling is simple enough.
>> 
>> However, for this to work, I think I need a require transformer, but I'm at 
>> a loss. The only example I see can mess with the module path, but not the 
>> symbols it exposes.
>> 
>> Any pointers?
>> 
>> --
>> 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.
> 
> 
> 
> -- 
> Jay McCarthy
> Associate Professor
> PLT @ CS @ UMass Lowell
> http://jeapostrophe.github.io
> 
>   "Wherefore, be not weary in well-doing,
>  for ye are laying the foundation of a great work.
> And out of small things proceedeth that which is great."
>  - D 64:33
> 
> -- 
> 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] Require Transformers

2016-06-29 Thread Jay McCarthy
I think you want this:

#lang racket/base
(require (for-syntax racket/base
 syntax/parse
 racket/require-transform
 racket/syntax))

(define-syntax ns-in
  (make-require-transformer
   (λ (stx)
 (syntax-parse stx
   [(_ mp:id)
(with-syntax ([mp: (format-id #'mp "~a:" #'mp)])
  (expand-import
   (syntax/loc stx
 (prefix-in mp: mp]

(module+ test
  (require (ns-in racket/list))
  racket/list:empty)

On Wed, Jun 29, 2016 at 9:05 AM, Shakna Israel  wrote:
> I'm trying to introduce an implicit binding for require.
>
> One of the features I love about Python, is the namespace binding.
>
> import sys
>
> sys.stdout.write("Sweet")
>
> I know this can also be accomplished with require by specifying a prefix-in, 
> or a prefix-out with a local-require.
>
> However, I want a require that does that for me.
>
> (require racket/base)
> (racket/base:println "It works!")
>
> Figuring the namespace mangling is simple enough.
>
> However, for this to work, I think I need a require transformer, but I'm at a 
> loss. The only example I see can mess with the module path, but not the 
> symbols it exposes.
>
> Any pointers?
>
> --
> 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.



-- 
Jay McCarthy
Associate Professor
PLT @ CS @ UMass Lowell
http://jeapostrophe.github.io

   "Wherefore, be not weary in well-doing,
  for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
  - D 64:33

-- 
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] Require Transformers

2016-06-29 Thread Alex Knauth

> On Jun 29, 2016, at 9:05 AM, Shakna Israel  wrote:
> 
> I'm trying to introduce an implicit binding for require.
> 
> One of the features I love about Python, is the namespace binding.
> 
> import sys
> 
> sys.stdout.write("Sweet")
> 
> I know this can also be accomplished with require by specifying a prefix-in, 
> or a prefix-out with a local-require.
> 
> However, I want a require that does that for me.
> 
> (require racket/base)
> (racket/base:println "It works!")

Would something like

(require syntax/parse/define (for-syntax racket/base racket/syntax))
(begin-for-syntax
  (define-syntax-class path
[pattern path:id #:with prefix (format-id #'path "~a:" #'path)]))
(define-simple-macro (new-require path:path ...)
  (require (prefix-in path.prefix path.path) ...))

Work for you?

> Figuring the namespace mangling is simple enough.
> 
> However, for this to work, I think I need a require transformer, but I'm at a 
> loss. The only example I see can mess with the module path, but not the 
> symbols it exposes.
> 
> Any pointers?

-- 
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.