Re: [racket-users] Capability security in Racket?

2015-08-27 Thread Sean Lynch
Just thought I'd give everyone an update since it's been a little while. At
the moment I'm implementing my stripped-down language as a module language
that exports a subset of racket/base (and probably some other modules once
I get through the huge number of symbols in racket/base). Because "no
global mutable state" turns out to be much harder than I initially expected
due to needing to detect closures with mutable variables, I just decided to
start with immutable or simulated immutable datatypes (i.e. bytes but no
functionality to mutate them) and then add mutability back in.

It's been slow going because I only end up spending a half hour a night
between the time the kids finally settle down in bed and the time I go to
bed myself, and sometimes my brain is too fried to focus on it. Once I have
an initial stab at the set of symbols to include in the language I'll post
some code.

Of course, with no mutable state, there can be no capabilities, so figuring
out how to implement state and make it easy to create limited capabilities
to access that state will be the next step. Right now I'm thinking
something along the lines of Clojure's agents in that they will be first
class citizens with mutable references to immutable values representing
state, updated by asynchronous messages, but encapsulated and requiring
messages both for reading and mutation ala Erlang/OTP's gen_server. I guess
there is no reason they couldn't be closures just like E objects. I tried
some early experiments using hashes of serializable closures (using
web-server/lang/serial-lambda), but those appear to silently discard set!s
to local variables between calls, and having set! at all is somewhat
problematic. So even if they are implemented as closures, it seems like I
will probably need some opaque (to untrusted code) syntactic machinery to
ensure that there is no state that can't be serialized and deserialized,
and that mutation and inspection outside the object's methods requires a
capability. If I use a box to store the object's state, for example, I have
to make sure there isn't a way to make a box that is reachable from a
global variable.

Speaking of making boxes, that reminds me that I probably also need to
strip down the reader, lest someone do (define foo #&17). It might be
harmless without set-box! or box-cas!, but it should be an error since they
are at best not particularly useful without the mutator functions.

On Wed, Aug 19, 2015 at 10:40 PM Jack Firth  wrote:

> This idea in general is very cool, so do let us (or at least me) know when
> you've got a prototype working. I'm quite curious to see the inner workings.
>
> --
> 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] Frog/Scribble: h* tag substitution

2015-08-27 Thread Jordan Johnson
Hi all,

I’m using Greg Hendershott’s Frog[1] tool for my web site, and since I know I’m 
outputting HTML I sometimes want to be able to tell Frog/Scribble, “Just use 
this HTML tag here.” I’ve looked at the docs on implementing styles[2], and 
came up with this attempt:

> ;; string? -> (string? ... -> element?)
> (define (tag-function tag-name)
>   (lambda content
> (keyword-apply elem
>'(#:style)
>(list (style #f (list (alt-tag tag-name
>content)))

This worked great for inserting EM and STRONG tags:

> @(define em (tag-function "em”))
> ...
> Here’s something @em{really important}!
> ...

What’s got me baffled is that if I try to access H1..H5 tags this way, other 
tags get substituted. For example:

> @(define h3 (tag-function "h3”))
> ...
> @h3{Section 2}

renders as

> Section 2


So far it’s just the H* tags I’ve found misbehaving.

So, my plea to Greg & other Scribblers: can you give any insight into where the 
H3 might be getting replaced with an H1?

Thanks,
Jordan

[1] https://github.com/greghendershott/frog
[2] http://docs.racket-lang.org/scribble/extra-style.html

-- 
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] namespace-undefine-variable! question

2015-08-27 Thread Jos Koot
Of course there are easier methods, yours included. (I used the method of
defining a new language years ago to implement a lazy lambda-calculus, it
should be in the archives of this user's list)
 
What I now have is a toy meta-circular interpreter consisting of one single
symbolic expression acceptable to both racket/base and the interpreter
itself, using racket/base as bootstrap. My toy language does not include
define-forms.(it does include multiple values and makes no distinction
between syntactic and variable bindings; it has some crude tools to define
new hygienic macros; It includes a curry-option that automatically curries
procedure calls and even syntactic forms; I am working on a version that
includes a lazy-option, even for for the expr in (set! var expr))  I have
tested the metacircularity to 5 levels deep. Earlier experience has shown
me that an interpreter may seem metacircular to some levels but then fails
at one level deeper.
 
My interpreter includes a trace option (something like debug in DrRacket,
but much simpler and simply printing the process of evaluation). For this
trace-option I need the same parameter for all levels of meta-circularity,
or otherwise the trace-option can enter an infinite printing loop (for
example when tracing a printer procedure attached as prop:custom-write to a
struct-type). Therefore I use a parameter from a base-namespace that allows
disabling tracing at all levels of metacircularity, but have to hide it
from the user. That's why I want to undefine some variables of the base-
namespace I use to borrow variables crom racket/base. Of cource I could use
a parameter defined outside the interpreter itself, but I want my
interpreter to be written within the intersection of its own language and
racket/base. I don't want my interpreter to depend on a parameter defined
outside the interpreter itself, for in this way the interpreter would not
realy be metacircular. I also want my interpreter to correctly handle
syntaxes and procedures coming from a dictinct instance of the module that
defines the interpreter. Therefore it is important that I import a
parameter from a base-namespace for disabling tracing. (it remains possible
to fool my interpreter, though)
 
As I said, it is just a toy and certainly has no value as a languag for
real life programs. In addition, my interpreter does not obey the principle
of the distinction between expansion, compilation and run-time phases of
Racket. A key principle in my interprreter is that tthere is no distinction
between expansion and run time: the name of a syntacic form is bound as a
variable during the evaluation. This may be very wrong, but I am just
playing around.
 
Thanks for your comment, Jos
 
 

  _  

From: Deren Dohoda [mailto:deren.doh...@gmail.com] 
Sent: jueves, 27 de agosto de 2015 20:19
To: Jos Koot
Cc: Jens Axel Søgaard; Racket-Users List
Subject: Re: [racket-users] namespace-undefine-variable! question


Hi Jos,
>But some of them I want to undefine.

Isn't it easier to make your own restricted #lang and then use make-module-
evaluator? Sorry to butt in.


Deren


On Thu, Aug 27, 2015 at 1:24 PM, Jos Koot  wrote:



Thanks for your prompt and clear reply.
I admit I don't fully understand the map? argument.
Just by trying out I know that for my purposes I always have to provide
true for the map? argument.
Meanwhile I insert the namespace-set-variable-value! line with true map?
argument, as you suggest.
Thanks again,
Jos

  _  

From: jensaxelsoega...@gmail.com [mailto:jensaxelsoega...@gmail.com] On
Behalf Of Jens Axel Søgaard
Sent: jueves, 27 de agosto de 2015 17:35
To: Jos Koot
Cc: Racket-Users List
Subject: Re: [racket-users] namespace-undefine-variable! question


The issue here is whether the namespance's identifier mapping is used or
not. 

The documentation for namespace-undefine-variable! says:


Removes the sym variable, if any, in the top-level environment of
namespace in 
its base phase. The namespace’s identifier mapping (see Namespaces) is
 unaffected.



We can see that  list  is use the identifier mapping by changing the second
argument of namespace-variable-value to #f.


#lang racket
(define ns (make-base-namespace))
(namespace-variable-value 'list #f (λ () 'not-found) ns)

which evaluates to 'not-found.

Inserting your own non-imported value for  list  makes the identifier non-
imported and has
the happy side-effect of making namespace-undefined-variable! capable of
removing the
binding from namespace.

In some sense  namespace-undefined-variable!  miss an map? argument.
Your solution: insert, then undefine  seem to be the best solution for now.

/Jens Axel

you n



2015-08-27 16:53 GMT+02:00 Jos Koot :



The following works:
 
#lang racket/base
#;1 (define ns (make-base-namespace))
#;2 (namespace-variable-value 'list #t (λ () 'not-found) ns)
; -> #
#;3 (namespace-set-variable-value! 'list 'whatever (λ () #f) ns)
#;4 (namespace-undefine-variable! 'list ns)
#;5 (names

Re: [racket-users] namespace-undefine-variable! question

2015-08-27 Thread Deren Dohoda
Hi Jos,
>But some of them I want to undefine.
Isn't it easier to make your own restricted #lang and then use
make-module-evaluator? Sorry to butt in.

Deren

On Thu, Aug 27, 2015 at 1:24 PM, Jos Koot  wrote:

> Thanks for your prompt and clear reply.
> I admit I don't fully understand the map? argument.
> Just by trying out I know that for my purposes I always have to provide
> true for the map? argument.
> Meanwhile I insert the namespace-set-variable-value! line with true map?
> argument, as you suggest.
> Thanks again,
> Jos
>
> --
> *From:* jensaxelsoega...@gmail.com [mailto:jensaxelsoega...@gmail.com] *On
> Behalf Of *Jens Axel Søgaard
> *Sent:* jueves, 27 de agosto de 2015 17:35
> *To:* Jos Koot
> *Cc:* Racket-Users List
> *Subject:* Re: [racket-users] namespace-undefine-variable! question
>
> The issue here is whether the namespance's identifier mapping is used or
> not.
>
> The documentation for namespace-undefine-variable! says:
>
> Removes the sym variable, if any, in the top-level environment of
> namespace in
> its base phase. The namespace’s identifier mapping (see Namespaces) is
>  unaffected.
>
> We can see that  list  is use the identifier mapping by changing the
> second argument of namespace-variable-value to #f.
>
> #lang racket
> (define ns (make-base-namespace))
> (namespace-variable-value 'list #f (λ () 'not-found) ns)
>
> which evaluates to 'not-found.
>
> Inserting your own non-imported value for  list  makes the identifier
> non-imported and has
> the happy side-effect of making namespace-undefined-variable! capable of
> removing the
> binding from namespace.
>
> In some sense  namespace-undefined-variable!  miss an map? argument.
> Your solution: insert, then undefine  seem to be the best solution for now.
>
> /Jens Axel
>
> you n
>
>
> 2015-08-27 16:53 GMT+02:00 Jos Koot :
>
>> The following works:
>>
>> #lang racket/base
>> #;1 (define ns (make-base-namespace))
>> #;2 (namespace-variable-value 'list #t (λ () 'not-found) ns)
>> ; -> #
>> #;3 (namespace-set-variable-value! 'list 'whatever (λ () #f) ns)
>> #;4 (namespace-undefine-variable! 'list ns)
>> #;5 (namespace-variable-value 'list#t (λ () 'not-found) ns)
>> ; -> not-found
>>
>> But when I omit line 3 it does not work:
>>
>> #lang racket/base
>> #;1 (define ns (make-base-namespace))
>> #;2 (namespace-variable-value 'list #t (λ () 'not-found) ns) ; ->
>> #
>> #;4 (namespace-undefine-variable! 'list ns)
>> ;-> error namespace-undefine-variable!: given name is not defined
>> ;   name: list
>>
>> This I did with: Welcome to DrRacket, version
>> 6.2.0.5--2015-07-06(d6fa581/a) [3m].
>> Code in the definitions window. The problem is not typical for 'list
>> only.
>> The same happens with (at least some) other variables of a base-namespace.
>>
>> I have no clue why commenting out line 3 gives an error.
>> Do I misinterpret the docs on namespaces?
>>
>> Thanks, Jos
>>
>> PS I use a base-namespace in a toy interpreter.
>> It allows me to easily borrow all variables from a base-namespace.
>> But some of them I want to undefine.
>>
>>
>>
>>
>> --
>> 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.
>

-- 
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] namespace-undefine-variable! question

2015-08-27 Thread Jos Koot
Thanks for your prompt and clear reply.
I admit I don't fully understand the map? argument.
Just by trying out I know that for my purposes I always have to provide
true for the map? argument.
Meanwhile I insert the namespace-set-variable-value! line with true map?
argument, as you suggest.
Thanks again,
Jos

  _  

From: jensaxelsoega...@gmail.com [mailto:jensaxelsoega...@gmail.com] On
Behalf Of Jens Axel Søgaard
Sent: jueves, 27 de agosto de 2015 17:35
To: Jos Koot
Cc: Racket-Users List
Subject: Re: [racket-users] namespace-undefine-variable! question


The issue here is whether the namespance's identifier mapping is used or
not. 

The documentation for namespace-undefine-variable! says:


Removes the sym variable, if any, in the top-level environment of
namespace in 
its   base phase. The
namespace’s   identifier mapping (see
Namespaces  ) is
 unaffected.



We can see that  list  is use the identifier mapping by changing the second
argument of namespace-variable-value to #f.


#lang racket
(define ns (make-base-namespace))
(namespace-variable-value 'list #f (λ () 'not-found) ns)

which evaluates to 'not-found.

Inserting your own non-imported value for  list  makes the identifier non-
imported and has
the happy side-effect of making namespace-undefined-variable! capable of
removing the
binding from namespace.

In some sense  namespace-undefined-variable!  miss an map? argument.
Your solution: insert, then undefine  seem to be the best solution for now.

/Jens Axel

you n



2015-08-27 16:53 GMT+02:00 Jos Koot :



The following works:
 
#lang racket/base
#;1 (define ns (make-base-namespace))
#;2 (namespace-variable-value 'list #t (λ () 'not-found) ns)
; -> #
#;3 (namespace-set-variable-value! 'list 'whatever (λ () #f) ns)
#;4 (namespace-undefine-variable! 'list ns)
#;5 (namespace-variable-value 'list#t (λ () 'not-found) ns)
; -> not-found
 
But when I omit line 3 it does not work:
 

#lang racket/base
#;1 (define ns (make-base-namespace))
#;2 (namespace-variable-value 'list #t (λ () 'not-found) ns) ; ->
#
#;4 (namespace-undefine-variable! 'list ns)
;-> error namespace-undefine-variable!: given name is not defined
;   name: list


This I did with: Welcome to DrRacket, version 6.2.0.5--2015-07-
06(d6fa581/a) [3m].
Code in the definitions window. The problem is not typical for 'list only.
The same happens with (at least some) other variables of a base-namespace.
 
I have no clue why commenting out line 3 gives an error.
Do I misinterpret the docs on namespaces?
 
Thanks, Jos
 
PS I use a base-namespace in a toy interpreter.
It allows me to easily borrow all variables from a base-namespace.
But some of them I want to undefine.

 
 
 



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


Re: [racket-users] namespace-undefine-variable! question

2015-08-27 Thread Jens Axel Søgaard
The issue here is whether the namespance's identifier mapping is used or
not.

The documentation for namespace-undefine-variable! says:

Removes the sym variable, if any, in the top-level environment of
namespace in
its base phase
.
The namespace’s identifier

mapping
(see Namespaces
)
is
 unaffected.

We can see that  list  is use the identifier mapping by changing the second
argument of namespace-variable-value to #f.

#lang racket
(define ns (make-base-namespace))
(namespace-variable-value 'list #f (λ () 'not-found) ns)

which evaluates to 'not-found.

Inserting your own non-imported value for  list  makes the identifier
non-imported and has
the happy side-effect of making namespace-undefined-variable! capable of
removing the
binding from namespace.

In some sense  namespace-undefined-variable!  miss an map? argument.
Your solution: insert, then undefine  seem to be the best solution for now.

/Jens Axel

you n


2015-08-27 16:53 GMT+02:00 Jos Koot :

> The following works:
>
> #lang racket/base
> #;1 (define ns (make-base-namespace))
> #;2 (namespace-variable-value 'list #t (λ () 'not-found) ns)
> ; -> #
> #;3 (namespace-set-variable-value! 'list 'whatever (λ () #f) ns)
> #;4 (namespace-undefine-variable! 'list ns)
> #;5 (namespace-variable-value 'list#t (λ () 'not-found) ns)
> ; -> not-found
>
> But when I omit line 3 it does not work:
>
> #lang racket/base
> #;1 (define ns (make-base-namespace))
> #;2 (namespace-variable-value 'list #t (λ () 'not-found) ns) ; ->
> #
> #;4 (namespace-undefine-variable! 'list ns)
> ;-> error namespace-undefine-variable!: given name is not defined
> ;   name: list
>
> This I did with: Welcome to DrRacket, version
> 6.2.0.5--2015-07-06(d6fa581/a) [3m].
> Code in the definitions window. The problem is not typical for 'list only.
> The same happens with (at least some) other variables of a base-namespace.
>
> I have no clue why commenting out line 3 gives an error.
> Do I misinterpret the docs on namespaces?
>
> Thanks, Jos
>
> PS I use a base-namespace in a toy interpreter.
> It allows me to easily borrow all variables from a base-namespace.
> But some of them I want to undefine.
>
>
>
>
> --
> 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] namespace-undefine-variable! question

2015-08-27 Thread Jos Koot
The following works:
 
#lang racket/base
#;1 (define ns (make-base-namespace))
#;2 (namespace-variable-value 'list #t (λ () 'not-found) ns)
; -> #
#;3 (namespace-set-variable-value! 'list 'whatever (λ () #f) ns)
#;4 (namespace-undefine-variable! 'list ns)
#;5 (namespace-variable-value 'list#t (λ () 'not-found) ns)
; -> not-found
 
But when I omit line 3 it does not work:
 
#lang racket/base
#;1 (define ns (make-base-namespace))
#;2 (namespace-variable-value 'list #t (λ () 'not-found) ns) ; ->
#
#;4 (namespace-undefine-variable! 'list ns)
;-> error namespace-undefine-variable!: given name is not defined
;   name: list

This I did with: Welcome to DrRacket, version 6.2.0.5--2015-07-06(d6fa581/a)
[3m].
Code in the definitions window. The problem is not typical for 'list only.
The same happens with (at least some) other variables of a base-namespace.
 
I have no clue why commenting out line 3 gives an error.
Do I misinterpret the docs on namespaces?
 
Thanks, Jos
 
PS I use a base-namespace in a toy interpreter.
It allows me to easily borrow all variables from a base-namespace.
But some of them I want to undefine.
 
 
 

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