Re: [fonc] Macros, JSON

2013-07-22 Thread Chris Gahan
Hey John,

If you don't mind me asking, what's the higher level goal of this tool
you're making? Are you interested in transforming JSON? Querying JSON?

If you're interested in queries, Freebase has a very nice graph query
system (called MQL) where the user gives it a JSON structure as a query
template, and the database does some graph traversal and returns a
collection of JSON structures that match the template.

I think it's a really nice system; you can see some examples here:
http://www.freebase.com/query

The basic idea is that your JSON query template has some key/values for it
to match (eg: artist: The Police), and whatever values are left blank
(eg: album: []) gets populated with results. It has the littany of
standard database query features as well, like ordering and limits and
ranges and whatnot: http://mql.freebaseapps.com

Hope this helps!
-- Chris


On Sun, Jul 21, 2013 at 4:45 PM, John Carlson yottz...@gmail.com wrote:

 Or numbers for pointers...
 On Jul 21, 2013 3:43 PM, John Carlson yottz...@gmail.com wrote:

 I think what would be more difficult would be identifying what is
 persistent and what is runtime values.  Also, JSON doesn't contain
 pointers, so one would have to use strings for pointers.
 On Jul 21, 2013 3:22 PM, James McCartney asy...@gmail.com wrote:


 I thought about this briefly. One issue is how to distinguish literal
 strings from identifiers.

 On Sun, Jul 21, 2013 at 10:28 AM, John Carlson yottz...@gmail.comwrote:

 Hmm.  I've been thinking about creating a macro language written in
 JSON that operates on JSON structures.  Has someone done similar work?
 Should I just create a JavaScript AST in JSON? Or should I create an AST
 specifically for JSON manipulation?

 Thanks,

 John

 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc




 --
 --- james mccartney
 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc


 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc


___
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc


Re: [fonc] Macros, JSON

2013-07-22 Thread John Carlson
I was introduced to freebase by James Burke's (of Connections fame--highly
recommended TV series) k-web project and played with it some.  I am more
interested in transforming JSON with macro-JSON, with the possibility of
macro-JSON transforming itself.

However if freebase has implemented some kind of historical gazetteer
(including temporal information), that would interest me a lot.  I imagine
showing a globe collapsing as the speed of communication between points is
reduced.

What I mean by persistent below is things that remain constant between runs
of a macro program.  For example,  in comparing a value to null, the null
is made persistent in the macro, but not necessarily in the thing the macro
is processing.  Another thing that might be considered constant is the
number of predicates in a conditional branch.  My hope with
macro-macro-JSON is to make those things more flexible.  Perhaps even
bordering on genetic algorithms.

I am hoping to find a multiuser JSON editor with an excellent API.  If EDN
already has such an editor, I will consider using it.  Pointers anyone?
On Jul 22, 2013 6:14 PM, Chris Gahan ch...@ill-logic.com wrote:

 Hey John,

 If you don't mind me asking, what's the higher level goal of this tool
 you're making? Are you interested in transforming JSON? Querying JSON?

 If you're interested in queries, Freebase has a very nice graph query
 system (called MQL) where the user gives it a JSON structure as a query
 template, and the database does some graph traversal and returns a
 collection of JSON structures that match the template.

 I think it's a really nice system; you can see some examples here:
 http://www.freebase.com/query

 The basic idea is that your JSON query template has some key/values for it
 to match (eg: artist: The Police), and whatever values are left blank
 (eg: album: []) gets populated with results. It has the littany of
 standard database query features as well, like ordering and limits and
 ranges and whatnot: http://mql.freebaseapps.com

 Hope this helps!
 -- Chris


 On Sun, Jul 21, 2013 at 4:45 PM, John Carlson yottz...@gmail.com wrote:

 Or numbers for pointers...
 On Jul 21, 2013 3:43 PM, John Carlson yottz...@gmail.com wrote:

 I think what would be more difficult would be identifying what is
 persistent and what is runtime values.  Also, JSON doesn't contain
 pointers, so one would have to use strings for pointers.
 On Jul 21, 2013 3:22 PM, James McCartney asy...@gmail.com wrote:


 I thought about this briefly. One issue is how to distinguish literal
 strings from identifiers.

 On Sun, Jul 21, 2013 at 10:28 AM, John Carlson yottz...@gmail.comwrote:

 Hmm.  I've been thinking about creating a macro language written in
 JSON that operates on JSON structures.  Has someone done similar work?
 Should I just create a JavaScript AST in JSON? Or should I create an AST
 specifically for JSON manipulation?

 Thanks,

 John

 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc




 --
 --- james mccartney
 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc


 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc



 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc


___
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc


Re: [fonc] Macros, JSON

2013-07-22 Thread John Carlson
Well, I also think querying is a good idea.  I think I will need the
equivalent of XPath or perhaps XQuery for indexing stuff in JSON.  I think
I'm targetting my stuff to replace XSLT, if that is possible.  I'd like it
to be done with end-user programming inside and between editors.  Something
more concrete than XSLT.
On Jul 22, 2013 6:14 PM, Chris Gahan ch...@ill-logic.com wrote:

 Hey John,

 If you don't mind me asking, what's the higher level goal of this tool
 you're making? Are you interested in transforming JSON? Querying JSON?

 If you're interested in queries, Freebase has a very nice graph query
 system (called MQL) where the user gives it a JSON structure as a query
 template, and the database does some graph traversal and returns a
 collection of JSON structures that match the template.

 I think it's a really nice system; you can see some examples here:
 http://www.freebase.com/query

 The basic idea is that your JSON query template has some key/values for it
 to match (eg: artist: The Police), and whatever values are left blank
 (eg: album: []) gets populated with results. It has the littany of
 standard database query features as well, like ordering and limits and
 ranges and whatnot: http://mql.freebaseapps.com

 Hope this helps!
 -- Chris


 On Sun, Jul 21, 2013 at 4:45 PM, John Carlson yottz...@gmail.com wrote:

 Or numbers for pointers...
 On Jul 21, 2013 3:43 PM, John Carlson yottz...@gmail.com wrote:

 I think what would be more difficult would be identifying what is
 persistent and what is runtime values.  Also, JSON doesn't contain
 pointers, so one would have to use strings for pointers.
 On Jul 21, 2013 3:22 PM, James McCartney asy...@gmail.com wrote:


 I thought about this briefly. One issue is how to distinguish literal
 strings from identifiers.

 On Sun, Jul 21, 2013 at 10:28 AM, John Carlson yottz...@gmail.comwrote:

 Hmm.  I've been thinking about creating a macro language written in
 JSON that operates on JSON structures.  Has someone done similar work?
 Should I just create a JavaScript AST in JSON? Or should I create an AST
 specifically for JSON manipulation?

 Thanks,

 John

 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc




 --
 --- james mccartney
 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc


 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc



 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc


___
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc


Re: [fonc] Macros, JSON

2013-07-21 Thread James McCartney
I thought about this briefly. One issue is how to distinguish literal
strings from identifiers.

On Sun, Jul 21, 2013 at 10:28 AM, John Carlson yottz...@gmail.com wrote:

 Hmm.  I've been thinking about creating a macro language written in JSON
 that operates on JSON structures.  Has someone done similar work?  Should I
 just create a JavaScript AST in JSON? Or should I create an AST
 specifically for JSON manipulation?

 Thanks,

 John

 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc




-- 
--- james mccartney
___
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc


Re: [fonc] Macros, JSON

2013-07-21 Thread Alan Moore
As an alternative to JSON you might consider EDN:

https://github.com/edn-format/edn

Alan


On Jul 21, 2013, at 11:46 AM, John Carlson yottz...@gmail.com wrote:

Hmm.  I've been thinking about creating a macro language written in JSON
that operates on JSON structures.  Has someone done similar work?  Should I
just create a JavaScript AST in JSON? Or should I create an AST
specifically for JSON manipulation?

Thanks,

John

___
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc
___
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc


Re: [fonc] Macros, JSON

2013-07-21 Thread Alan Moore
JSON is all well and good as far as lowest common denominators go. However,
you might want to consider EDN:

https://github.com/edn-format/edn

On the other hand, if you are doing that then you might as well go *all*
the way and re-invent half of Common Lisp :-)

http://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule

Alan Moore


On Sun, Jul 21, 2013 at 10:28 AM, John Carlson yottz...@gmail.com wrote:

 Hmm.  I've been thinking about creating a macro language written in JSON
 that operates on JSON structures.  Has someone done similar work?  Should I
 just create a JavaScript AST in JSON? Or should I create an AST
 specifically for JSON manipulation?

 Thanks,

 John

 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc


___
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc


Re: [fonc] Macros, JSON

2013-07-21 Thread John Carlson
You would have to create a JSON object which would have key (identifier),
value pairs.
On Jul 21, 2013 3:22 PM, James McCartney asy...@gmail.com wrote:


 I thought about this briefly. One issue is how to distinguish literal
 strings from identifiers.

 On Sun, Jul 21, 2013 at 10:28 AM, John Carlson yottz...@gmail.com wrote:

 Hmm.  I've been thinking about creating a macro language written in JSON
 that operates on JSON structures.  Has someone done similar work?  Should I
 just create a JavaScript AST in JSON? Or should I create an AST
 specifically for JSON manipulation?

 Thanks,

 John

 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc




 --
 --- james mccartney
 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc


___
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc


Re: [fonc] Macros, JSON

2013-07-21 Thread John Carlson
I think what would be more difficult would be identifying what is
persistent and what is runtime values.  Also, JSON doesn't contain
pointers, so one would have to use strings for pointers.
On Jul 21, 2013 3:22 PM, James McCartney asy...@gmail.com wrote:


 I thought about this briefly. One issue is how to distinguish literal
 strings from identifiers.

 On Sun, Jul 21, 2013 at 10:28 AM, John Carlson yottz...@gmail.com wrote:

 Hmm.  I've been thinking about creating a macro language written in JSON
 that operates on JSON structures.  Has someone done similar work?  Should I
 just create a JavaScript AST in JSON? Or should I create an AST
 specifically for JSON manipulation?

 Thanks,

 John

 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc




 --
 --- james mccartney
 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc


___
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc


Re: [fonc] Macros, JSON

2013-07-21 Thread John Carlson
Or numbers for pointers...
On Jul 21, 2013 3:43 PM, John Carlson yottz...@gmail.com wrote:

 I think what would be more difficult would be identifying what is
 persistent and what is runtime values.  Also, JSON doesn't contain
 pointers, so one would have to use strings for pointers.
 On Jul 21, 2013 3:22 PM, James McCartney asy...@gmail.com wrote:


 I thought about this briefly. One issue is how to distinguish literal
 strings from identifiers.

 On Sun, Jul 21, 2013 at 10:28 AM, John Carlson yottz...@gmail.comwrote:

 Hmm.  I've been thinking about creating a macro language written in JSON
 that operates on JSON structures.  Has someone done similar work?  Should I
 just create a JavaScript AST in JSON? Or should I create an AST
 specifically for JSON manipulation?

 Thanks,

 John

 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc




 --
 --- james mccartney
 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc


___
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc


Re: [fonc] Macros, JSON

2013-07-21 Thread John Carlson
What makes this important is whether your running in stateless or stateful
mode.  If you only run the macro once no big deal.  If you try to run on a
server, you may find that you need to reset items like cursors to their
original values.
On Jul 21, 2013 3:43 PM, John Carlson yottz...@gmail.com wrote:

 I think what would be more difficult would be identifying what is
 persistent and what is runtime values.  Also, JSON doesn't contain
 pointers, so one would have to use strings for pointers.
 On Jul 21, 2013 3:22 PM, James McCartney asy...@gmail.com wrote:


 I thought about this briefly. One issue is how to distinguish literal
 strings from identifiers.

 On Sun, Jul 21, 2013 at 10:28 AM, John Carlson yottz...@gmail.comwrote:

 Hmm.  I've been thinking about creating a macro language written in JSON
 that operates on JSON structures.  Has someone done similar work?  Should I
 just create a JavaScript AST in JSON? Or should I create an AST
 specifically for JSON manipulation?

 Thanks,

 John

 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc




 --
 --- james mccartney
 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc


___
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc


Re: [fonc] Macros, JSON

2013-07-21 Thread John Carlson
Hmm.  Seems like someone has already done XMLisp.  I thought s-expressions
were the lowest common denominator.
JSON is all well and good as far as lowest common denominators go. However,
you might want to consider EDN:

https://github.com/edn-format/edn

On the other hand, if you are doing that then you might as well go *all*
the way and re-invent half of Common Lisp :-)

http://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule

Alan Moore


On Sun, Jul 21, 2013 at 10:28 AM, John Carlson yottz...@gmail.com wrote:

 Hmm.  I've been thinking about creating a macro language written in JSON
 that operates on JSON structures.  Has someone done similar work?  Should I
 just create a JavaScript AST in JSON? Or should I create an AST
 specifically for JSON manipulation?

 Thanks,

 John

 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc



___
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc
___
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc


Re: [fonc] Macros, JSON

2013-07-21 Thread Casey Ransberger
Lisp is such a joy to implement. FORTH is fun too.

I'm working on a scheme-alike on and off. The idea is to take the message 
passing and delegation from Self, expose it in Lisp, and then map all of that 
to JavaScript. 

One idea I had when I was messing around with OMetaJS was that it might have 
some kind of escape syntax like

(let ((x 1))
  #{x++; }#
)

Would basically mean

(let ((x 1))
  (+ x 1))

...which would make doing primitives feel pretty smooth, and also give you 
the nice JSON syntax.

The rule is simple too, '#{' followed by anything:a up until '}#' - eval(a)

Only problem is relating environment context between the two languages, which I 
haven't bothered to figure out yet. The JS eval() in this case is insufficient.

(Sorry about the pseudocode, on a phone and don't keep OMeta syntax in my 
head...)

On Jul 21, 2013, at 1:15 PM, Alan Moore kahunamo...@closedsource.com wrote:

 JSON is all well and good as far as lowest common denominators go. However, 
 you might want to consider EDN:
 
 https://github.com/edn-format/edn
 
 On the other hand, if you are doing that then you might as well go *all* the 
 way and re-invent half of Common Lisp :-)
 
 http://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule
 
 Alan Moore
 
 
 On Sun, Jul 21, 2013 at 10:28 AM, John Carlson yottz...@gmail.com wrote:
 Hmm.  I've been thinking about creating a macro language written in JSON that 
 operates on JSON structures.  Has someone done similar work?  Should I just 
 create a JavaScript AST in JSON? Or should I create an AST specifically for 
 JSON manipulation?
 
 Thanks,
 
 John
 
 
 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc
 
 
 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc
___
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc


Re: [fonc] Macros, JSON

2013-07-21 Thread Casey Ransberger
Probably a more usable language would be arrived upon via some extensions to 
JSON. May I recommend OMetaJS? :)

The lack of a unique atomic symbolic literal as distinct from a string is one 
of the things I'm grappling with right now. To get that I'd need to intern the 
atoms. Jury's out whether it's a good idea to try to used JS typed arrays to 
implement the symbol interning or to use an under the hood tag on the string 
at the intermediate level to distinguish them (hidden from the programmer who 
just sees a Lisp alike.)

On Jul 21, 2013, at 1:45 PM, John Carlson yottz...@gmail.com wrote:

 Or numbers for pointers...
 
 On Jul 21, 2013 3:43 PM, John Carlson yottz...@gmail.com wrote:
 I think what would be more difficult would be identifying what is persistent 
 and what is runtime values.  Also, JSON doesn't contain pointers, so one 
 would have to use strings for pointers.
 
 On Jul 21, 2013 3:22 PM, James McCartney asy...@gmail.com wrote:
 
 I thought about this briefly. One issue is how to distinguish literal strings 
 from identifiers.
 
 On Sun, Jul 21, 2013 at 10:28 AM, John Carlson yottz...@gmail.com wrote:
 Hmm.  I've been thinking about creating a macro language written in JSON that 
 operates on JSON structures.  Has someone done similar work?  Should I just 
 create a JavaScript AST in JSON? Or should I create an AST specifically for 
 JSON manipulation?
 
 Thanks,
 
 John
 
 
 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc
 
 
 
 
 -- 
 --- james mccartney 
 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc
 
 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc
___
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc


Re: [fonc] Macros, JSON

2013-07-21 Thread Tristan Slominski
All this talk of macros and quotes reminds me that there is Kernel language
where they are extraneous (if I understand it correctly). Operative and
applicative combiners are used explicitly:
http://www.wpi.edu/Pubs/ETD/Available/etd-090110-124904/unrestricted/jshutt.pdf


On Sun, Jul 21, 2013 at 5:06 PM, Casey Ransberger
casey.obrie...@gmail.comwrote:

 Lisp is such a joy to implement. FORTH is fun too.

 I'm working on a scheme-alike on and off. The idea is to take the message
 passing and delegation from Self, expose it in Lisp, and then map all of
 that to JavaScript.

 One idea I had when I was messing around with OMetaJS was that it might
 have some kind of escape syntax like

 (let ((x 1))
   #{x++; }#
 )

 Would basically mean

 (let ((x 1))
   (+ x 1))

 ...which would make doing primitives feel pretty smooth, and also give
 you the nice JSON syntax.

 The rule is simple too, '#{' followed by anything:a up until '}#' -
 eval(a)

 Only problem is relating environment context between the two languages,
 which I haven't bothered to figure out yet. The JS eval() in this case is
 insufficient.

 (Sorry about the pseudocode, on a phone and don't keep OMeta syntax in my
 head...)

 On Jul 21, 2013, at 1:15 PM, Alan Moore kahunamo...@closedsource.com
 wrote:

 JSON is all well and good as far as lowest common denominators go.
 However, you might want to consider EDN:

 https://github.com/edn-format/edn

 On the other hand, if you are doing that then you might as well go *all*
 the way and re-invent half of Common Lisp :-)

 http://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule

 Alan Moore


 On Sun, Jul 21, 2013 at 10:28 AM, John Carlson yottz...@gmail.com wrote:

 Hmm.  I've been thinking about creating a macro language written in JSON
 that operates on JSON structures.  Has someone done similar work?  Should I
 just create a JavaScript AST in JSON? Or should I create an AST
 specifically for JSON manipulation?

 Thanks,

 John

 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc


 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc


 ___
 fonc mailing list
 fonc@vpri.org
 http://vpri.org/mailman/listinfo/fonc


___
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc


Re: [fonc] Macros, JSON

2013-07-21 Thread BGB

On 7/21/2013 12:28 PM, John Carlson wrote:


Hmm.  I've been thinking about creating a macro language written in 
JSON that operates on JSON structures.  Has someone done similar 
work?  Should I just create a JavaScript AST in JSON? Or should I 
create an AST specifically for JSON manipulation?




my scripting language mostly uses S-Expressions for its AST format.

my C frontend mostly used an XML variant.
I had a few times considered a hybrid, essentially like XML with a more 
compact syntax (*1).


in the future, most likely I would just use S-Expressions.
while S-Exps are slightly more effort in some cases to extend, they are 
generally faster than manipulating XML, and are easier to work with.



JSON could work, but its syntax is slightly more than what is needed for 
something like this, and its data representation isn't necessarily ideal.


EDN looks ok.


*1:
node := '' tag (key'='value)* node* ''
tag key=value tag2 key2=val2 tag3

where value was a literal value with one of several types, IIRC:
integer type;
floating-point type;
string.

note that there were no free-floating raw values.
a free-floating value would instead be wrapped in a node.

had also considered using square braces:
[array [int val=1234] [real val=3.14] [string val=string] [symbol 
val=symbol]]


the allowed forms would otherwise have been fairly constrained.
the constrained structure would be mostly for sake of performance and 
similar.


note:
the XML variant used by my C frontend also ended up (quietly) adding 
support for raw numeric values, mostly because of the added overhead of 
converting between strings and numbers.




Thanks,

John



___
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc


___
fonc mailing list
fonc@vpri.org
http://vpri.org/mailman/listinfo/fonc