[erlang-questions] announce SEGB-0.1

Joe Armstrong erlang@REDACTED
Fri Feb 11 21:20:40 CET 2011


On Fri, Feb 11, 2011 at 8:43 PM, James Churchman
<jameschurchman@REDACTED>wrote:

> looks really cool!
>
> two things tho,
>
> 1) i cant get it to work, i get when visiting
> http://localhost:1234/generic.html
> Uncaught ReferenceError: SVG is not defined
> in chromium
> and
> generic.html:20 <http://localhost:1234/generic.html>ReferenceError: Can't
> find variable: SVG
> in safari :-)
>
> maybe its because i dot have genuine chrome on my mac, but the function
> SVG() does not exist
>

Oops - I've fixed this - thanks. SVG was a private library that I was
playing with


>
> and 2)
>
> im fairly sure that this in the docs is not quite correct
>
> *var glob = new Array();*
>
> To persist a variable outside the scope of eval we can evaluate: *eval('var
> glob[Name] = ...');* since*glob* is defined outside of the scope of eval
> its value will be persisted outside the scope of eval.
>
> I think that eval always runs at the scope that its at, but putting in
> "var" restricts the scope to either the eval or two the scope that its in
> (eg the function). I think its the latter. Simply leaving out the var
> statement (as it does in the code :-) ) makes it global (eg attach to the
> window object)
>

I didn't know that. I tried eval("var foo=.....") follow by an
access to var via eval("...x(foo) ..") and concluded that foo
was not known to the garbage collector and removed. I didn't try
the eval("foo = ..") variant.

I actually have no idea how long data persists in javascript, especially
code. I assume data structures are garbed away
if they are not reachable form the DOM or the top level of
all javscript that has been loaded, but how to remove a js script
is a mystery ...

/Joe





> james
>
> On 11 Feb 2011, at 18:08, Joe Armstrong wrote:
>
> Announcing SEBG-0.1
>
> SEBG = Simple Erlang Browser Graphics
>
> This is a system to push graphics to a browser.
>
> Using this you can make interactive graphics in a websockets enabled
> browser
> in a few lines of code.
>
> It consists of a simple web server. The browser
> opens a web socket and the web server spawns a process to
> handle the socket. I set up a middle man to handle the socket.
> Thereafter the handler can push asynchronous messages to the browser.
>
> These message contain Javascript expressions. All the code in the
> browser does is wait for a message, eval it and wait for the next message.
>
> Then I make sure jquery and Raphael are loaded, after which
> I send Javascript messages to the browser contain Javascript expressions
> that create SVG objects by calling library functions in Raphael
>
> The code for all of this is surprisingly simple, and it is very easy to
> push
> asynchronous message to the browser.
>
> I have also included a number of suggests for projects based on this.
> This list often gets request for suitable problems to solve. Building on
> this simple code it should be possible to implement simple multi-user
> games and so on. Being able to push asynchronous messages to the browser
> makes like very easy.
>
> Have a look. The code is at
>
> https://github.com/joearms/SEBG
>
> Cheers
>
> /Joe
>
>
>


More information about the erlang-questions mailing list