Re: [racket-users] Running racket on a #lang-less module-less file?

2016-05-05 Thread Robby Findler
As a meta-point, one thing our experience with trying to put together
multiple files in different languages into programs suggests that
putting the information telling us which language a given file
supposed to be in should be with the file, not with the reference to
the file (and not nowhere). That said, I think Matthew's tool
suggestion is fills a practical need and until someone implements
that, Matthias's solution should work great.

Robby


On Thu, May 5, 2016 at 8:05 PM, William Hatch  wrote:
> I've always thought that should be possible -- for instance, if someone were
> to implement some pre-existing language in Racket, it would be nice to be
> able to say "require this using #lang X" so that it can be parsed and bound
> correctly.  Eg. if you had a Javascript implementation and some functions to
> massage data between what normal Racket and Javascript-inside-Racket expect,
> it might be fun to be able to consume some node.js libraries that way.  At
> least for libraries that work within whatever implementation you might have.
>
>
> On Thu, May 5, 2016 at 6:45 PM, Jack Firth  wrote:
>>
>> On Thursday, May 5, 2016 at 5:39:44 PM UTC-7, Matthew Flatt wrote:
>> > At Thu, 5 May 2016 17:32:20 -0700 (PDT), Jack Firth wrote:
>> > > Does that evaluate the file as if it were entered in a REPL?
>> >
>> > Yes.
>>
>> What if I don't want REPL semantics, but I want behavior identical to if
>> the file began with the appropriate #lang line? Is there some subtle reason
>> that's not an option?
>>
>> --
>> 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] Running racket on a #lang-less module-less file?

2016-05-05 Thread Matthew Flatt
I think something like this could be made to work as, say, a `raco`
command.

If it were really implemented by writing to a new file, then source
locations would all be wrong, of course. But it looks like the `#lang`
protocol might work with an input stream that is different from the one
that named the language.

Supporting a prefix like `#lang at-exp racket` seems tricky, because
`at-exp` would need to receive an input port that concatenates " racket
" with the input file, and I doubt that the port source-location
protocol can deal with it nicely. Probably the right idea is to support
only simple `#lang` prefixes.

Having a `require` form that adds an implicit `#lang` (if I understand
what William is suggesting) sounds too difficult to be practical, since
that would imply a change to all tools that deal with module files.

At Thu, 5 May 2016 21:14:28 -0400, Matthias Felleisen wrote:
> 
> I might be a bit lost here but can’t you do the moral equivalent of this: 
> 
>  cat my-dsl.rkt program-in-my-dsl.rkt > crude.rkt; racket crude.rkt 
> 
> where my-dsl.rkt is
> 
> #lang racket/base ;; or your favorite #lang line 
> 
> and  program-in-my-dsl.rkt is 
> 
>  (displayln "I am in my special language now”)
> 
> You probably don’t want to see the racket on the command line anyway, so why 
> not camouflage the addition of the #lang line while you’re at it? 
> 
> — Matthias
> 
> 
> 
> 
> 
> 
> 
> > On May 5, 2016, at 9:05 PM, William Hatch  wrote:
> > 
> > I've always thought that should be possible -- for instance, if someone 
> > were 
> to implement some pre-existing language in Racket, it would be nice to be 
> able 
> to say "require this using #lang X" so that it can be parsed and bound 
> correctly.  Eg. if you had a Javascript implementation and some functions to 
> massage data between what normal Racket and Javascript-inside-Racket expect, 
> it might be fun to be able to consume some node.js libraries that way.  At 
> least for libraries that work within whatever implementation you might have.
> > 
> > 
> > On Thu, May 5, 2016 at 6:45 PM, Jack Firth  > wrote:
> > On Thursday, May 5, 2016 at 5:39:44 PM UTC-7, Matthew Flatt wrote:
> > > At Thu, 5 May 2016 17:32:20 -0700 (PDT), Jack Firth wrote:
> > > > Does that evaluate the file as if it were entered in a REPL?
> > >
> > > Yes.
> > 
> > What if I don't want REPL semantics, but I want behavior identical to if 
> > the 
> file began with the appropriate #lang line? Is there some subtle reason 
> that's 
> not an option?
> > 
> > --
> > 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.

-- 
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] Running racket on a #lang-less module-less file?

2016-05-05 Thread Matthias Felleisen

I might be a bit lost here but can’t you do the moral equivalent of this: 

 cat my-dsl.rkt program-in-my-dsl.rkt > crude.rkt; racket crude.rkt 

where my-dsl.rkt is

#lang racket/base ;; or your favorite #lang line 

and  program-in-my-dsl.rkt is 

 (displayln "I am in my special language now”)

You probably don’t want to see the racket on the command line anyway, so why 
not camouflage the addition of the #lang line while you’re at it? 

— Matthias







> On May 5, 2016, at 9:05 PM, William Hatch  wrote:
> 
> I've always thought that should be possible -- for instance, if someone were 
> to implement some pre-existing language in Racket, it would be nice to be 
> able to say "require this using #lang X" so that it can be parsed and bound 
> correctly.  Eg. if you had a Javascript implementation and some functions to 
> massage data between what normal Racket and Javascript-inside-Racket expect, 
> it might be fun to be able to consume some node.js libraries that way.  At 
> least for libraries that work within whatever implementation you might have.
> 
> 
> On Thu, May 5, 2016 at 6:45 PM, Jack Firth  > wrote:
> On Thursday, May 5, 2016 at 5:39:44 PM UTC-7, Matthew Flatt wrote:
> > At Thu, 5 May 2016 17:32:20 -0700 (PDT), Jack Firth wrote:
> > > Does that evaluate the file as if it were entered in a REPL?
> >
> > Yes.
> 
> What if I don't want REPL semantics, but I want behavior identical to if the 
> file began with the appropriate #lang line? Is there some subtle reason 
> that's not an option?
> 
> --
> 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] Running racket on a #lang-less module-less file?

2016-05-05 Thread William Hatch
I've always thought that should be possible -- for instance, if someone
were to implement some pre-existing language in Racket, it would be nice to
be able to say "require this using #lang X" so that it can be parsed and
bound correctly.  Eg. if you had a Javascript implementation and some
functions to massage data between what normal Racket and
Javascript-inside-Racket expect, it might be fun to be able to consume some
node.js libraries that way.  At least for libraries that work within
whatever implementation you might have.


On Thu, May 5, 2016 at 6:45 PM, Jack Firth  wrote:

> On Thursday, May 5, 2016 at 5:39:44 PM UTC-7, Matthew Flatt wrote:
> > At Thu, 5 May 2016 17:32:20 -0700 (PDT), Jack Firth wrote:
> > > Does that evaluate the file as if it were entered in a REPL?
> >
> > Yes.
>
> What if I don't want REPL semantics, but I want behavior identical to if
> the file began with the appropriate #lang line? Is there some subtle reason
> that's not an option?
>
> --
> 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] Running racket on a #lang-less module-less file?

2016-05-05 Thread Jack Firth
On Thursday, May 5, 2016 at 5:39:44 PM UTC-7, Matthew Flatt wrote:
> At Thu, 5 May 2016 17:32:20 -0700 (PDT), Jack Firth wrote:
> > Does that evaluate the file as if it were entered in a REPL?
> 
> Yes.

What if I don't want REPL semantics, but I want behavior identical to if the 
file began with the appropriate #lang line? Is there some subtle reason that's 
not an option?

-- 
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] Running racket on a #lang-less module-less file?

2016-05-05 Thread Matthew Flatt
At Thu, 5 May 2016 17:32:20 -0700 (PDT), Jack Firth wrote:
> On Thursday, May 5, 2016 at 5:28:06 PM UTC-7, Matthew Flatt wrote:
> > At Thu, 5 May 2016 17:14:57 -0700 (PDT), Jack Firth wrote:
> > > Suppose I have a file in some custom language, like #lang foo, but it 
> omits 
> > > the #lang foo line. Is there a way I can run the racket command line 
> program 
> > > in a way where it says "treat this file as if it starts with the line 
> #lang 
> > > foo"?
> > 
> > Not in general, but if a language supports the top level, then
> > 
> >  racket -I  -f 
> > 
> > might work.
> 
> Is that a lowercase L or an uppercase i? Both seem to work.

Either could work, but an uppercase "I" avoids first loading `racket`.

> Does that evaluate the file as if it were entered in a REPL?

Yes.

-- 
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] Running racket on a #lang-less module-less file?

2016-05-05 Thread Jack Firth
On Thursday, May 5, 2016 at 5:28:06 PM UTC-7, Matthew Flatt wrote:
> At Thu, 5 May 2016 17:14:57 -0700 (PDT), Jack Firth wrote:
> > Suppose I have a file in some custom language, like #lang foo, but it omits 
> > the #lang foo line. Is there a way I can run the racket command line 
> > program 
> > in a way where it says "treat this file as if it starts with the line #lang 
> > foo"?
> 
> Not in general, but if a language supports the top level, then
> 
>  racket -I  -f 
> 
> might work.

Is that a lowercase L or an uppercase i? Both seem to work. Does that evaluate 
the file as if it were entered in a REPL?

-- 
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] Running racket on a #lang-less module-less file?

2016-05-05 Thread Matthew Flatt
At Thu, 5 May 2016 17:14:57 -0700 (PDT), Jack Firth wrote:
> Suppose I have a file in some custom language, like #lang foo, but it omits 
> the #lang foo line. Is there a way I can run the racket command line program 
> in a way where it says "treat this file as if it starts with the line #lang 
> foo"?

Not in general, but if a language supports the top level, then

 racket -I  -f 

might work.

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