1
Name:
Anonymous
2014-01-11 17:38
Lets discuss writing Lisp interpreter on top of SQL.
I already did the reader part...
https://github.com/saniv/tsql_lisp/blob/master/lisp.sql
2
Name:
Anonymous
2014-01-11 17:44
Also, I have an idea, that SQL Lisp implementation should use huge rows, instead of cons-pairs, to speed up queries. Rows should have index on head to do funcalls efficiently.
3
Name:
Anonymous
2014-01-11 17:44
That looks like the offspring of COBOL and BASIC.
4
Name:
Anonymous
2014-01-11 17:56
>>3
that is why we need something better there.
5
Name:
Anonymous
2014-01-11 18:38
Look up AP5 (and "Relational Lisp") in general.
Also look at the expert system Lisp like languages like CLIPS.
7
Name:
Anonymous
2014-01-11 19:43
>>5
AP5
What's that shit? Poor man's JSON with some COBOL-era layers on top?
8
Name:
Anonymous
2014-01-11 19:52
>>7
WTF? Are you sure you're looking at the right thing? AP5 is NOT a data interchange format.
10
Name:
Anonymous
2014-01-12 3:30
So in a nutshell relational Lisp would get you
(animal cat Name (lambda (Age) (< Age 3))
while SQL provides:
select * from Animals where 'animal_type' = 'cat' AND 'age' < 3
but I'm more interested in implementing usual imperative Lisp on top of SQL.
11
Name:
Anonymous
2014-01-12 4:04
>>10
Yeah do that but also put the relational stuff in "for free" so to speak.
12
Name:
Anonymous
2014-01-12 5:40
>>11
Sorry, I'm just exploring the ways relational database could help storing and querying typical imperative code.
MSSQL appears to have some native support for storing SEXPs in the form of XML, although I'm not sure how useful it is.
13
Name:
Anonymous
2014-01-12 5:44
>>12
And it looks amazingly unintuitive...
Given this table structure:
create table MyTable (Roles XML)
insert into MyTable values
('<root>
<role>Alpha</role>
<role>Gamma</role>
<role>Beta</role>
</root>')
We can query it like this:
select * from
(select
pref.value('(text())[1]', 'varchar(32)') as RoleName
from
MyTable CROSS APPLY
Roles.nodes('/root/role') AS Roles(pref)
) as Result
where RoleName like '%ga%'
14
Name:
Anonymous
2014-01-13 14:11
Anyways, it is finished. Lambda, map and reduce work as expected.
https://raw2.github.com/saniv/tsql_lisp/master/example2.png
Sad news: SQL Server limits recursion to 32 depth.
15
Name:
Anonymous
2014-01-13 15:02
>>14
Sad news: SQL Server limits recursion to 32 depth.
Oy vey
! What a bunch of anti-Schemites
!