Using lisp to generate .net business applications

204 views
Skip to first unread message

prabuinet

unread,
Oct 26, 2006, 3:35:07 AM10/26/06
to
hi,

I googled and got this link of a slide show presented in lisp
conference by Alex Peake...

http://www.international-lisp-conference.org/2005/media/peake-slides.pdf

I'm trying to do the same (generate c# from lisp) since I think its a
good idea.

But i'm a newbie to lisp, who just read the 'practical common lisp'
book..

I dont know how to start with this...

Any little idea from lisp guru's here would help me to get started with
my work...

thankx in advance

bye

Ralph Allan Rice

unread,
Oct 26, 2006, 9:50:08 AM10/26/06
to

Could you elaborate on what your goals are? Reading the slides and
your statements, I see a few routes you can take:

1) Have Common Lisp interoperate with the .NET framework.

2) Find an implementation that can compile into MSIL / CIL.

3) Have Common Lisp generate C# source code to be fed into another
compiler.


--
Ralph

Joe Marshall

unread,
Oct 26, 2006, 6:30:03 PM10/26/06
to

I wrote a demo for Alex at the conference using the .NET api in Common
Larceny.
Common Larceny is a version of Scheme, not Common Lisp, but it might
give you some ideas about how to go about doing what you want. You
should be able to port the code using Edi Weitz's RDNZL interface to
.NET. You can get Common Larceny from http://larceny.ccs.neu.edu/ The
demo code I wrote is in Lib\MzScheme\CodeDOM-demo.sch

prabuinet

unread,
Oct 26, 2006, 10:28:59 PM10/26/06
to

Hi Ralph,

I want the third one

"3) Have Common Lisp generate C# source code to be fed into another
compiler."

I'm trying to do this, but didn't get an idea as I mentioned already.
This is what Alex Peake have also did.

I don't know how all stuffs of .net's Properties, Methods, Classes,
Namespaces...
can come under brackets (LISP)

thanks for reply.

Prabu

prabuinet

unread,
Oct 26, 2006, 11:09:59 PM10/26/06
to

On Oct 27, 3:30 am, "Joe Marshall" <eval.ap...@gmail.com> wrote:
> prabuinet wrote:
> > hi,
>
> > I googled and got this link of a slide show presented in lisp
> > conference by Alex Peake...
>
> >http://www.international-lisp-conference.org/2005/media/peake-slides.pdf
>
> > I'm trying to do the same (generate c# from lisp) since I think its a
> > good idea.
>
> > But i'm a newbie to lisp, who just read the 'practical common lisp'
> > book..
>
> > I dont know how to start with this...
>
> > Any little idea from lisp guru's here would help me to get started with

> > my work...I wrote a demo for Alex at the conference using the .NET api in Common


> Larceny.
> Common Larceny is a version of Scheme, not Common Lisp, but it might
> give you some ideas about how to go about doing what you want. You
> should be able to port the code using Edi Weitz's RDNZL interface to
> .NET. You can get Common Larceny from http://larceny.ccs.neu.edu/ The
> demo code I wrote is in Lib\MzScheme\CodeDOM-demo.sch

I'm not looking for such solution,
and also both Common Larceny and RDNZL have one thing in common - No
proper documentation.

Prabu

Pascal Bourguignon

unread,
Oct 27, 2006, 1:28:52 AM10/27/06
to
"prabuinet" <prab...@gmail.com> writes:
> I want the third one
>
> "3) Have Common Lisp generate C# source code to be fed into another
> compiler."
>
> I'm trying to do this, but didn't get an idea as I mentioned already.
> This is what Alex Peake have also did.
>
> I don't know how all stuffs of .net's Properties, Methods, Classes,
> Namespaces...
> can come under brackets (LISP)

If you write functions such as:

(defun generate-statement (statement &key same-line)
(if (atom statement)
(progn ;; label
(unless same-line (emit :newline))
(emit statement ":"))
(case (first statement)
((c-sharp::block c-sharp::progn c-sharp::tagbody)
(emit "{")
(map nil (function generate-statement) (rest statement))
(emit :newline "}"))
((c-sharp::if)
(unless same-line (emit :newline))
(case (length statement)
(3
(emit "if" "(")
(generate-expression (second statement) :naked t)
(emit ")")
(generate-statement (third statement)))
(4
(emit "if" "(")
(generate-expression (second statement) :naked t)
(emit ")")
(generate-statement (third statement))
(emit "else")
(generate-statement (fourth statement)))
(otherwise
(error "Syntax error in ~S; ~%~
Expected syntax: (IF condition then-statement [else-statement])~%~
Got: ~S" (first statement) statement))))
...)))

then you can use them as:

(generate-statement '(c-sharp::progn
(printf "\\nHello\\n")
(c-sharp::if (c-sharp::== 0 var-1)
(printf "var2 = %d\\n" var-2)
(printf "var1 = %d\\n" var-1))))


and get something like:

{
printf("\nHello\n");
if(0==var1)
printf("var2 = %d\n",var2);else
printf("var1 = %d\n",var1);
}


(You just need to pass it thru emacs's indent-region to get a nice
C/C++/C# whatever source).


Then with some macrology nicely packaged, you can convert files
containing lisp code into C#, with a simple:

(compile-file-to-c-sharp "mypgm.lincshap")

Have a look at: http://www.evaluator.pt/linj.html

--
__Pascal Bourguignon__ http://www.informatimago.com/

"Do not adjust your mind, there is a fault in reality"
-- on a wall many years ago in Oxford.

prabuinet

unread,
Oct 27, 2006, 7:59:18 AM10/27/06
to


http://www.evaluator.pt/linj.html seems to be dead link.

U gave a good example, thank u. I will work it out.

bye

Pascal Bourguignon

unread,
Oct 27, 2006, 8:31:12 AM10/27/06
to
"prabuinet" <prab...@gmail.com> writes:
> http://www.evaluator.pt/linj.html seems to be dead link.

Not for me :-)
It's in Portugal, but my traceroutes going thru New York can reach it.


> U gave a good example, thank u. I will work it out.

--
__Pascal Bourguignon__ http://www.informatimago.com/

"Indentation! -- I will show you how to indent when I indent your skull!"

Ralph Allan Rice

unread,
Oct 27, 2006, 5:17:10 PM10/27/06
to

I think it is certainly possible. One can just output the C# code
outright to a file, but that's not a very lispy solution, IMO. I did
run into one library called Parenscript (http://parenscript.org) that I
am currently evaluating. It's interprets Common Lisp forms and
transforms it to Javascript on-the-fly. I use it for some toy web
applications. It's not exactly a solution you were looking for, but
might give you a good starting point. I do not see any reason why it
can't be modified to output C#. The license is BSD, so you can look at
it yourself.

Hope this helps.
--
Ralph

prabuinet

unread,
Oct 28, 2006, 5:21:46 AM10/28/06
to
> I think it is certainly possible. One can just output the C# code
> outright to a file, but that's not a very lispy solution, IMO.
> I did run into one library called Parenscript (http://parenscript.org) that I
> am currently evaluating. It's interprets Common Lisp forms and
> transforms it to Javascript on-the-fly. I use it for some toy web
> applications. It's not exactly a solution you were looking for, but
> might give you a good starting point. I do not see any reason why it
> can't be modified to output C#. The license is BSD, so you can look at
> it yourself.
>
> Hope this helps.
> --
Hi,

I dont think that Alex Peake would have did some thing like
'Parentscript' , since lot of work to be done to do so.. (Writing a
compiler.. to convert lisp expressions to c#). He also didn't
mentioned as he did a compiler.. He was just metaprogramming with lisp,
and its format statement..

I tried ... and got something like this...

(defmacro lstring (x)
`(string-downcase (string ,x)))

(defmacro emit (&rest params)
`(format t ,@params))

(defun table (tname field-list)
(progn
(emit "~%private void create~atable() { " (lstring tname))
(emit "~%~t~tdt.TableName = \"~a\"" (lstring tname))
(dolist (field field-list)
(emit "~%~t~tdt.Columns.Add(~a, typeof(~a));" (lstring (car field))
(lstring (cadr field))))
(emit "~%}")))

(table 'student
'((name varchar)
(age int)
(gender bool)))


.. the last expression outputs the following csharp function

private void createstudenttable() {
dt.TableName = "student"
dt.Columns.Add(name, typeof(varchar));
dt.Columns.Add(age, typeof(int));
dt.Columns.Add(gender, typeof(bool));
}


I don't know how this would be better than template based
metaprogramming or anything else.

One of the difficulty with this approach for every such output function
i want to use the same emit calls again and again... The syntax of
csharp is hidden with in such emit calls..

Does the funciton 'table' look like a macro for csharp.

Prabu

Javier

unread,
Oct 28, 2006, 9:38:14 AM10/28/06
to
prabuinet ha escrito:

> "3) Have Common Lisp generate C# source code to be fed into another
> compiler."

Why don't you use just C#? Is there anything wrong about using it
directly?

prabuinet

unread,
Oct 28, 2006, 9:41:49 AM10/28/06
to

Javier wrote:

> Why don't you use just C#? Is there anything wrong about using it
> directly?

To avoid lots of typing...

Javier

unread,
Oct 28, 2006, 10:12:53 AM10/28/06
to

prabuinet ha escrito:

In the time you have invested learning Lisp, you could have typed all
the code. Even worse: do you know that most IDEs today have macros to
avoid typing? For example, in NetBeans you write "sout" and appears
System.out.println(""). You can create your own macro for anything you
desire to avoid typing, and you don't need to switch between languages,
which is always a pain.

Pascal Costanza

unread,
Oct 28, 2006, 10:42:16 AM10/28/06
to

These are only ad hoc solutions. With Lisp you can systematically avoid
typing, so any investment in the beginning pays off in the long run.

Programming in Java is extremely painful, no matter what conveniences an
IDE provides. The problem here is that the IDE conveniences are only
workarounds for limitations in the language that shouldn't be there in
the first place.


Pascal

--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/

Pascal Bourguignon

unread,
Oct 28, 2006, 10:49:09 AM10/28/06
to
"prabuinet" <prab...@gmail.com> writes:

Indeed, table is a csharp macro. This is meta-programming.

Common Lisp, the ultimate universal preprocessor.

--
__Pascal Bourguignon__ http://www.informatimago.com/

"By filing this bug report you have challenged the honor of my
family. Prepare to die!"

Pascal Bourguignon

unread,
Oct 28, 2006, 11:10:43 AM10/28/06
to
"Javier" <jav...@gmail.com> writes:


Ah but, once you've typed sout all over the place, can you type soutd
and have everywhere you typed sout System.out.println("---------")
replace System.out.println("") ?


With lisp "macros", when you have:

(defun sout ()
(emit "~%System.out.println(\"\");"))

and you keep (sout) in the _source_ code, when you generate it the
first time you have System.out.println("") everywhere.
But when you need to change it, you can change it only at one place:

(defun sout ()
(emit "~%System.out.println(\"------------\");"))

and generate the code again and have System.out.println("------------");
everywhere now.

Of course, consider the leverage with more complex "macros" such as
prabuinet's TABLE.


--
__Pascal Bourguignon__ http://www.informatimago.com/

This is a signature virus. Add me to your signature and help me to live.

Javier

unread,
Oct 28, 2006, 11:20:13 AM10/28/06
to
Pascal Costanza wrote:
> Javier wrote:
> > prabuinet ha escrito:
> >
> >> Javier wrote:
> >>
> >>> Why don't you use just C#? Is there anything wrong about using it
> >>> directly?
> >> To avoid lots of typing...
> >
> > In the time you have invested learning Lisp, you could have typed all
> > the code. Even worse: do you know that most IDEs today have macros to
> > avoid typing? For example, in NetBeans you write "sout" and appears
> > System.out.println(""). You can create your own macro for anything you
> > desire to avoid typing, and you don't need to switch between languages,
> > which is always a pain.
>
> These are only ad hoc solutions. With Lisp you can systematically avoid
> typing, so any investment in the beginning pays off in the long run.
>
> Programming in Java is extremely painful, no matter what conveniences an
> IDE provides. The problem here is that the IDE conveniences are only
> workarounds for limitations in the language that shouldn't be there in
> the first place.

Can you give any example of such limitations which interferes with real
programming?
If I want to avoid typing, using an IDE macro is just nice, fast, and
produces code which everyone can understand at the first glance (if you
use Lisp macros, you first must understand what that macro is doing).
I don't think that having to type more or less code means that you are
going to be more productive at the end. If so, why writing
documentation? why writing long names for functions and variables?

And for abstracting things, you have a very good OOP language, both on
C# and Java.

Marc Battyani

unread,
Oct 28, 2006, 12:18:44 PM10/28/06
to
"Javier" <jav...@gmail.com> wrote:

> Pascal Costanza wrote:
>>
>> Programming in Java is extremely painful, no matter what conveniences an
>> IDE provides. The problem here is that the IDE conveniences are only
>> workarounds for limitations in the language that shouldn't be there in
>> the first place.
>
> Can you give any example of such limitations which interferes with real
> programming?

No MOP, no macros, no parentheses, a low power object model, a verbose
syntax, no on-the-fly code generation and execution, no generic functions,
no method combinations, no live system update, no REPL, etc.

Though I'm sure that there exists ad hoc, informally-specified, bug-ridden,
slow implementations of half of those. (*)

> If I want to avoid typing, using an IDE macro is just nice, fast, and
> produces code which everyone can understand at the first glance (if you
> use Lisp macros, you first must understand what that macro is doing).

You prefer to use things first and try to understand them later. (or never.)

> I don't think that having to type more or less code means that you are
> going to be more productive at the end. If so, why writing
> documentation? why writing long names for functions and variables?
>
> And for abstracting things, you have a very good OOP language, both on
> C# and Java.

Heh? You made a huge typo here, it's "pathetic" instead of "good".

Marc
(feeding the trolls today)
(*) Greenspun's Tenth Rule of Programming


prabuinet

unread,
Oct 28, 2006, 12:52:55 PM10/28/06
to
Customer to programmer: I want this.

Programmer to language like c# or Java : A long essay....

i'm expecting this to happen

Programmer to LISP: (eval (I want this)) => "A long essay..."

what i'm trying to say above is, many times customer will tell his
requirement in just a single line.

To do that single line of work. we want to spend lot of hours with a
language like c# or java.

I'm trying to bridge this gap with lisp,

Let Lisp do my work.

I'm a lazy programmer, and i hate to do my work if it is repitive. Once
taught should be taught forever if it is a good language. C# doesn't
provide me that facility...

It cant learn anything what i teach it...

but lisp could do...

Lisp can learn programming from me. Yes i'm speaking about lisp MACRO's

if c# had macro's i wouldn't have started this thread.

- Prabu

Pascal Costanza

unread,
Oct 28, 2006, 1:15:43 PM10/28/06
to
Javier wrote:
> Pascal Costanza wrote:
>> Javier wrote:
>>> prabuinet ha escrito:
>>>
>>>> Javier wrote:
>>>>
>>>>> Why don't you use just C#? Is there anything wrong about using it
>>>>> directly?
>>>> To avoid lots of typing...
>>> In the time you have invested learning Lisp, you could have typed all
>>> the code. Even worse: do you know that most IDEs today have macros to
>>> avoid typing? For example, in NetBeans you write "sout" and appears
>>> System.out.println(""). You can create your own macro for anything you
>>> desire to avoid typing, and you don't need to switch between languages,
>>> which is always a pain.
>> These are only ad hoc solutions. With Lisp you can systematically avoid
>> typing, so any investment in the beginning pays off in the long run.
>>
>> Programming in Java is extremely painful, no matter what conveniences an
>> IDE provides. The problem here is that the IDE conveniences are only
>> workarounds for limitations in the language that shouldn't be there in
>> the first place.
>
> Can you give any example of such limitations which interferes with real
> programming?

Yes, loads.

For starters, check out http://www.jwz.org/doc/java.html - although
that's an old rambling, most of it still applies. You can find all kinds
of listings of Java deficiencies by googling for the right keywords.

My own contribution is this: http://p-cos.net/documents/dynatype.pdf

Note: Attacking these specific examples is besides the point.

> If I want to avoid typing, using an IDE macro is just nice, fast, and
> produces code which everyone can understand at the first glance (if you
> use Lisp macros, you first must understand what that macro is doing).

My paper above gives an example where an "IDE macro" clearly does the
wrong thing (tm).

> I don't think that having to type more or less code means that you are
> going to be more productive at the end. If so, why writing
> documentation? why writing long names for functions and variables?

I thought the same a few years ago, when I was still a Java addict.

> And for abstracting things, you have a very good OOP language, both on
> C# and Java.

The problem with these "very good OOP languages" is that they have
contradicting (dynamic) class and (static) type inheritance. This is a
major source of the problems in those languages. Essentially, method
dispatch is based on the class of object - a dynamic property - while
static type checking wants to know as much as possible at compile time,
so needs static properties. If you throw both things in the same
language, you get lots of compromises that you constantly have to work
around. The euphemisms for these workarounds are "best practices" or
"idioms". They require a lot of typing, and this is what the IDEs save
you from doing. If you either have a "real" dynamic or a "real" static
language, you don't need these workarounds in the first place, because
the language is clear about how it works and can take full advantage of
its respective optimum in the design space.

If you want to work with a good "traditional" OOP language, try Smalltalk.

Marc Battyani

unread,
Oct 28, 2006, 1:27:54 PM10/28/06
to

"prabuinet" <prab...@gmail.com> wrote

Sure, no problem, do it. I did a few contracts like that a long, long, time
ago. In one case the customer wanted me to take a standard C++ business
application, with a lot of classes, and make a COM encapsulation of that. So
I wrote less than 700 LOC of Lisp and generated more than 20 kLOC of boring
COM/ATL code. It's even easier if you target a language with a garbage
collector.

Something link LINJ is quite good for this:
http://www.evaluator.pt/linj.html

Marc


Pascal Bourguignon

unread,
Oct 28, 2006, 1:51:45 PM10/28/06
to
"Javier" <jav...@gmail.com> writes:
> (if you use Lisp macros, you first must understand what that macro is doing).

This is wrong.

With well done abstraction, you don't need to understand what's under the hood.

This was one of my own HaHa moment, while reading lisp code, that you
don't actually need to know what's inside the macros.


--
__Pascal Bourguignon__ http://www.informatimago.com/

"I have challenged the entire quality assurance team to a Bat-Leth
contest. They will not concern us again."

Javier

unread,
Oct 28, 2006, 2:35:29 PM10/28/06
to
Marc Battyani ha escrito:

> "Javier" <jav...@gmail.com> wrote:
> > Pascal Costanza wrote:
> >>
> >> Programming in Java is extremely painful, no matter what conveniences an
> >> IDE provides. The problem here is that the IDE conveniences are only
> >> workarounds for limitations in the language that shouldn't be there in
> >> the first place.
> >
> > Can you give any example of such limitations which interferes with real
> > programming?
>
> No MOP,

You've got reflection and generics.

> no macros,

You don't need so if you abstract all your programing with objects.

> no parentheses,

eh?

> a low power object model,

Low power? I do have private, protected variables and method (Lisp
doesn't), I do have interfaces and abstract classes, which is a
_feature_, not a trick.

> a verbose
> syntax,

In your opinion, but lot of people find useful to know what types are
managing, for example.

> no on-the-fly code generation and execution,

What? You have dynamic class loader. You can generate and call any
class you like to whenever you need.

> no generic functions,

You've got polymorphic and abstract methods.

> no method combinations, no live system update, no REPL, etc.

You've got BeanShell, which is nice.
And you can update your program while it is running if you want. Lot of
IDEs can add plugins in real time, lot of applications written in Java
too.

> Though I'm sure that there exists ad hoc, informally-specified, bug-ridden,
> slow implementations of half of those. (*)
>
> > If I want to avoid typing, using an IDE macro is just nice, fast, and
> > produces code which everyone can understand at the first glance (if you
> > use Lisp macros, you first must understand what that macro is doing).
>
> You prefer to use things first and try to understand them later. (or never.)

This is precisely the problem of Lisp macros.

> > And for abstracting things, you have a very good OOP language, both on
> > C# and Java.
>
> Heh? You made a huge typo here, it's "pathetic" instead of "good".

Yeah, sure, and Lisp is the Last One Thing.

Marc Battyani

unread,
Oct 28, 2006, 3:35:33 PM10/28/06
to

"Javier" <jav...@gmail.com> wrote
> Marc Battyani ha escrito:

>
>> No MOP,
>
> You've got reflection and generics.

Huh? Either you didn't look at or you do not understand.
Have you at least read papers on this and the Common Lisp MOP? Have you read
what Pascal Costanza wrote several times here? If you don't understand ask
for more information instead of posting marketing jingles.

>> no macros,
>
> You don't need so if you abstract all your programing with objects.

OK, now I'm sure. You don't understand anything.

>> no parentheses,
>
> eh?

For this one you can have a joker. Often newbies don't grok this.

>> a low power object model,
>
> Low power? I do have private, protected variables and method (Lisp
> doesn't), I do have interfaces and abstract classes, which is a
> _feature_, not a trick.

It's starting to be really embarassing for you there.

[Skipped the other replies which show a complete lack of understanding of
any concept.]

> Yeah, sure, and Lisp is the Last One Thing.

It's a very good local optimum in the programming language space for power
and expressiveness. So are C and VHDL for instance, for other rating
functions. Even Java is very good for what made him grow popular: providing
the general IT market with standard plug and play programmers.

Marc
(OK I stop feeding the trolls now)


nha...@gmail.com

unread,
Oct 28, 2006, 10:38:20 PM10/28/06
to
prabuinet wrote:

> and also both Common Larceny and RDNZL have one thing in common - No
> proper documentation.

Which part of the RDNZL documentation did you not understand?

Cheers,
Edi.

Bill Atkins

unread,
Oct 28, 2006, 11:05:27 PM10/28/06
to
"Javier" <jav...@gmail.com> writes:

> Can you give any example of such limitations which interferes with real
> programming?
> If I want to avoid typing, using an IDE macro is just nice, fast, and
> produces code which everyone can understand at the first glance (if you
> use Lisp macros, you first must understand what that macro is doing).

You're being silly. I use C# in my day job, and I end up using very
similar bits of code disturbingly often, because the language is so
inflexible.

For example, I have a database-backed application that involves nearly
the same bit of code over and over: code to copy information from the
database to model objects (we need a model layer because the
application will soon be retrieving data from a web service rather
than from a direct database connection), code to copy model data to
label controls (for when the user is just viewing the data), code to
copy model data to editable controls (for when the user is making
changes), code to copy the data out of the editable controls into
model objects, and finally code to copy the information from the model
back into the database. When we make the switch to the web service
backend, this will require two more near-copies of this code.

With Lisp, I could write a macro or two explicitly describing the
links between these different parts of the program, and anyone could
extend the program by making straightforward changes to that one
macro. Show me an IDE macro that can do that.

> I don't think that having to type more or less code means that you are
> going to be more productive at the end. If so, why writing
> documentation? why writing long names for functions and variables?

Because more code is a greater semantic burden than documentation or
long variable names? More verbose, less expressive code is more
complicated to read and maintain.

> And for abstracting things, you have a very good OOP language, both on
> C# and Java.

Puh-shah.

Either learn Lisp, or stick with Java and C# and go hang out with
those guys. Nobody here wants to read your misinformed attempts at
trolling.

Ken Tilton

unread,
Oct 29, 2006, 3:41:35 AM10/29/06
to

I think for this retort to work you need "What part of
http://weitz.de/rdnzl/ did you not understand?".

kt

--
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
-- Smiling husband to scowling wife, New Yorker cartoon

prabuinet

unread,
Oct 29, 2006, 6:23:55 AM10/29/06
to

Ken Tilton wrote:
> > Which part of the RDNZL documentation did you not understand?
>
> I think for this retort to work you need "What part of
> http://weitz.de/rdnzl/ did you not understand?".
>

change in the special-reader-syntax.. [].. is it really necessary? cant
we do it with ()

one more problem..

i cant use sqlite.net.dll with RDNZL

i'm using (clisp, emacs slime) under cygwin.

rdnzl works fine. but i cant load the sqlite.net. dll.

i copied the dll to all these directories :
./,
/usr/lib/clisp/
/usr/bin

but still no result

nha...@gmail.com

unread,
Oct 29, 2006, 6:50:15 AM10/29/06
to
prabuinet wrote:

> change in the special-reader-syntax.. [].. is it really necessary? cant
> we do it with ()

1. The reader syntax is there (see documentation) "to make entering
.NET forms easier." You don't need to use it if you don't like it.

2. You want () instead of []? Try to patch RDNZL to achieve the effect
you want.

> one more problem..
>
> i cant use sqlite.net.dll with RDNZL

Send RDNZL-specific questions to the RDNZL mailing list.

So, that's what you mean with "no proper documentation?" I see...

Edi.

John Thingstad

unread,
Oct 29, 2006, 3:10:20 PM10/29/06
to
On Sun, 29 Oct 2006 12:23:55 +0100, prabuinet <prab...@gmail.com> wrote:

>
> rdnzl works fine. but i cant load the sqlite.net. dll.
>
> i copied the dll to all these directories :
> ./,
> /usr/lib/clisp/
> /usr/bin
>
> but still no result
>

.NET dosn't deal with dll's. The knowlege of the code location is stored
centrally.
Sqlite light would have to register the component in which case
it would be part of the .NET hirarcy. (Stored in the registry.)

Each .NET componet has a assemby which tells it how the component looks.
From this information RDNZL can build the Lisp interface.

If I were you I'd get Visual C# Express from Microsoft.

This will allow you to:
1. Make sure you have the developer version of .NET 2.0 installed
2. You can use the object browser to scan for .NET components.
3. Easy access to .NET documentation.

Usefull even if you don't want to use C#.

dexplorer.exe which is the interface to the documentation
for .NET, also regasm.exe which allows you to make a COM component
into a .NET component if you have written a assembly (a XML file),
and much more come with the .NET 2.0 developer installation.

I suspect it is information about the .NET library you miss,
but that is part of .NET not the Lisp interface.

To get C# hurry though, it will only remain free until November 7'th.

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Jim Sokoloff

unread,
Oct 30, 2006, 9:10:33 AM10/30/06
to

John Thingstad wrote:
> .NET dosn't deal with dll's. The knowlege of the code location is stored
> centrally.

.Net does "deal" with DLLs. You can load .Net DLLs/Assemblies
from a known/local directory, OR from the GAC*. For user-created
assemblies, I think it's much cleaner to load them NOT from the
GAC, and instead load them from "known" paths, such that you
can use two completely different versions of an assembly without
having to go through all the versioning compatability trouble and
re-testing. (My viewpoint is shaped from 4 years doing in-house
development of a complex top-10 e-commerce site. Other views
are certainly valid for other cases.)

> Sqlite light would have to register the component in which case
> it would be part of the .NET hirarcy. (Stored in the registry.)

If you use the GAC, yes. You are under no requirement/obligation
to do so.

> If I were you I'd get Visual C# Express from Microsoft.

Strongly seconded!!

> To get C# hurry though, it will only remain free until November 7'th.

Hadn't realized that. Thanks for the tip!

--Jim

* - GAC = Global Assembly Cache, roughly a central registry/
clearinghouse for .Net components on the machine.

markku_l...@yahoo.com

unread,
Oct 31, 2006, 1:11:59 AM10/31/06
to

Bill Atkins wrote:
> "Javier" <jav...@gmail.com> writes:
>
> > Can you give any example of such limitations which interferes with real
> > programming?
> > If I want to avoid typing, using an IDE macro is just nice, fast, and
> > produces code which everyone can understand at the first glance (if you
> > use Lisp macros, you first must understand what that macro is doing).
>
> You're being silly. I use C# in my day job, and I end up using very
> similar bits of code disturbingly often, because the language is so
> inflexible.
>
> For example, I have a database-backed application that involves nearly
> the same bit of code over and over: code to copy information from the
> database to model objects (we need a model layer because the
> application will soon be retrieving data from a web service rather
> than from a direct database connection), code to copy model data to
> label controls (for when the user is just viewing the data), code to
> copy model data to editable controls (for when the user is making
> changes), code to copy the data out of the editable controls into
> model objects, and finally code to copy the information from the model
> back into the database. When we make the switch to the web service
> backend, this will require two more near-copies of this code.

Well, when I started developing with C#, I used the same method myself.
This is really pain in the neck, if you are on the same time developing
the database schema (new project, new yet to finalized schema).

Instead of making changes to db code all the time, I wrote an
abstraction layer on top of any sql database scema.

When I have (some version) of the schema as an sql script with create
table & alter table statements, I run preprocessor, which will generate
access layer into db and from db.
So now I can write all DB access stuff using this layer.

I haven't yet implemented binding of the layer into web controls, but
is quite easy to achieve.

I have also been thinking about implementing some compiler/interpreter
from Common Lisp to C#. Would be fun to develop some apps with that
one.


Regards,
PKY

Prabu

unread,
Nov 10, 2006, 1:35:57 AM11/10/06
to

Pascal Bourguignon wrote:

> "prabuinet" <prab...@gmail.com> writes:
> > I want the third one
> >
> > "3) Have Common Lisp generate C# source code to be fed into another
> > compiler."
> >
> > I'm trying to do this, but didn't get an idea as I mentioned already.
> > This is what Alex Peake have also did.
> >
> > I don't know how all stuffs of .net's Properties, Methods, Classes,
> > Namespaces...
> > can come under brackets (LISP)
>
> If you write functions such as:
>
> (defun generate-statement (statement &key same-line)
> (if (atom statement)
> (progn ;; label
> (unless same-line (emit :newline))
> (emit statement ":"))
> (case (first statement)
> ((c-sharp::block c-sharp::progn c-sharp::tagbody)
> (emit "{")
> (map nil (function generate-statement) (rest statement))
> (emit :newline "}"))
> ((c-sharp::if)
> (unless same-line (emit :newline))
> (case (length statement)
> (3
> (emit "if" "(")
> (generate-expression (second statement) :naked t)
> (emit ")")
> (generate-statement (third statement)))
> (4
> (emit "if" "(")
> (generate-expression (second statement) :naked t)
> (emit ")")
> (generate-statement (third statement))
> (emit "else")
> (generate-statement (fourth statement)))
> (otherwise
> (error "Syntax error in ~S; ~%~
> Expected syntax: (IF condition then-statement [else-statement])~%~
> Got: ~S" (first statement) statement))))
> ...)))
>
> then you can use them as:
>
> (generate-statement '(c-sharp::progn
> (printf "\\nHello\\n")
> (c-sharp::if (c-sharp::== 0 var-1)
> (printf "var2 = %d\\n" var-2)
> (printf "var1 = %d\\n" var-1))))
>
>
> and get something like:
>
> {
> printf("\nHello\n");
> if(0==var1)
> printf("var2 = %d\n",var2);else
> printf("var1 = %d\n",var1);
> }
>
>
> (You just need to pass it thru emacs's indent-region to get a nice
> C/C++/C# whatever source).
>
>
> Then with some macrology nicely packaged, you can convert files
> containing lisp code into C#, with a simple:
>
> (compile-file-to-c-sharp "mypgm.lincshap")
>
> Have a look at: http://www.evaluator.pt/linj.html

>
> --
> __Pascal Bourguignon__ http://www.informatimago.com/
>
> "Do not adjust your mind, there is a fault in reality"
> -- on a wall many years ago in Oxford.

I got stuck with this...

how could we write this in lisp in a neat way

ds.Tables["Customer"].Rows[0]["Name"] = "Rose";

Pascal Bourguignon

unread,
Nov 10, 2006, 5:09:28 AM11/10/06
to
"Prabu" <prab...@gmail.com> writes:

> how could we write this in lisp in a neat way
>
> ds.Tables["Customer"].Rows[0]["Name"] = "Rose";

The standard way is:

(setf (gethash (aref (customer-rows (gethash (ds-tables ds) "Customer")) 0) "Name")
"Rose")

But most probably, you'd have functions or methods to access the
customer and name slots...

Anyways, the above expression can even be simplified, thanks to my
generalized accessor macro for example:

(setf (-> ds 'ds-tables "Customer" 'customer-rows 0 "Name") "Rose")

http://groups.google.com/group/comp.lang.lisp/msg/1bab4b5bae1fdca3?dmode=source


(defun (setf ->) (value object &rest path)
(if (null path)
(error "(setf ->) needs some path.")
(let ((last (car (last path))))
(let ((object (apply (function ->) object (butlast path))))
(cond
((arrayp object) (setf (aref object last) value))
((and (listp object)
(every (function consp) object)
(not (integerp last)))
(setf (cdr (assoc last object)) value))
((listp object) (setf (elt object last) value))
((hash-table-p object) (setf (gethash last object) value))
((typep object '(or structure-object standard-object))
(eval `(setf (,last ',object) ',value)))
((or (functionp (first path))
(and (symbolp (first path)) (fboundp (first path))))
(eval `(setf (,last ',object) ',value)))
(t (error "This is not a compound object: ~S" object)))))))

--
__Pascal Bourguignon__ http://www.informatimago.com/

Pour moi, la grande question n'a jamais été: «Qui suis-je? Où vais-je?»
comme l'a formulé si adroitement notre ami Pascal, mais plutôt:
«Comment vais-je m'en tirer?» -- Jean Yanne

Prabu

unread,
Nov 10, 2006, 11:27:17 PM11/10/06
to

> (setf (-> ds 'ds-tables "Customer" 'customer-rows 0 "Name") "Rose")

Is this Syntactic Abstraction ?

Pascal Bourguignon

unread,
Nov 10, 2006, 11:44:53 PM11/10/06
to
"Prabu" <prab...@gmail.com> writes:

>> (setf (-> ds 'ds-tables "Customer" 'customer-rows 0 "Name") "Rose")
>
> Is this Syntactic Abstraction ?

Exactly.

I've abstracted away the implementation details of arrays, hash-tables
lists, alists, structures and object slots, and even random functions.


--
__Pascal Bourguignon__ http://www.informatimago.com/

THIS IS A 100% MATTER PRODUCT: In the unlikely event that this
merchandise should contact antimatter in any form, a catastrophic
explosion will result.

Reply all
Reply to author
Forward
0 new messages