On 20 oct, 21:38, Nicolas Edel <············@gmail.com> wrote:
> On 20 oct, 21:28, Javier <·······@gmail.com> wrote:
>
> > As the title says, I want to create my own language.
> > I want it to have a similar syntax to Python (but I don't want it to
> > be Python, I have some ideas about it which are surely going to make
> > it incompatible).
> > I want it to be programmed in Lisp.
>
> What does that mean ? A language is not programmed, compilers or
> interpreters are. But this has nothing to do with the language itself.
There is no need to be so much "dense". You know what I meant.
> Briefly said, you want to create your own language but don't know much
> more about it... Not sure this is the best place for such a request.
Lisp is a language which is well suited for creating languages, isn't
it?
I'd like to ear opinions on ideas about possible implementations.
Javier wrote:
> On 20 oct, 21:38, Nicolas Edel <············@gmail.com> wrote:
>
>>On 20 oct, 21:28, Javier <·······@gmail.com> wrote:
>>
>>
>>>As the title says, I want to create my own language.
>>>I want it to have a similar syntax to Python (but I don't want it to
>>>be Python, I have some ideas about it which are surely going to make
>>>it incompatible).
>>>I want it to be programmed in Lisp.
>>
>>What does that mean ? A language is not programmed, compilers or
>>interpreters are. But this has nothing to do with the language itself.
>
>
> There is no need to be so much "dense". You know what I meant.
I didn't, and had the same questions. But I think it is just a little
ESL confusion. My quess is that you want to implement a new language
using Lisp.
If so, isn't SICP good on language implementation? And if the language
is going to be Lisp-y at least, maybe Lisp in Small Pieces would be useful?
I do not really know, last book I read was the Apple II Integer Basic guide.
Final thought: Just Do It? If you plan on sexpr notation for your new
language you can do it all with macrology.
hth,kt
On 21 oct, 00:09, Kenny <·········@gmail.com> wrote:
> Javier wrote:
> > On 20 oct, 21:38, Nicolas Edel <············@gmail.com> wrote:
>
> >>On 20 oct, 21:28, Javier <·······@gmail.com> wrote:
>
> >>>As the title says, I want to create my own language.
> >>>I want it to have a similar syntax to Python (but I don't want it to
> >>>be Python, I have some ideas about it which are surely going to make
> >>>it incompatible).
> >>>I want it to be programmed in Lisp.
>
> >>What does that mean ? A language is not programmed, compilers or
> >>interpreters are. But this has nothing to do with the language itself.
>
> > There is no need to be so much "dense". You know what I meant.
>
> I didn't, and had the same questions. But I think it is just a little
> ESL confusion. My quess is that you want to implement a new language
> using Lisp.
>
> If so, isn't SICP good on language implementation? And if the language
> is going to be Lisp-y at least, maybe Lisp in Small Pieces would be useful?
>
> I do not really know, last book I read was the Apple II Integer Basic guide.
>
> Final thought: Just Do It? If you plan on sexpr notation for your new
> language you can do it all with macrology.
>
> hth,kt
What do you think, something like this:
class ex2_class in database_variable
my_ex = 7 # initialized property
my_prop read read_prop write write_prop
def read_prop
if my_ex > 5
my_ex
else
0
def write_pop val
self.my_prop = val
def ex2_class
print "Constructing ex2_class"
def ex2_class val:integer # declaring val integer
print "Constructing ex2_class and passed a value of " val
def a_method:string a b # a method that returns the two strings
a and b concatenated
a $ b # a and b are now considered strings, so it is equivalent
to "a:string b:string"
# argument definition
def a_method a b
a+b #a and b are integers
def a_method a b
print a b # for any other case (not string nor integers)
The interesting thing would be to make something similar to Allegro
Cache integrated into this language, so you can create objects which
can reside both in memory and in a database.
Javier wrote:
> On 21 oct, 00:09, Kenny <·········@gmail.com> wrote:
>
>>Javier wrote:
>>
>>>On 20 oct, 21:38, Nicolas Edel <············@gmail.com> wrote:
>>
>>>>On 20 oct, 21:28, Javier <·······@gmail.com> wrote:
>>
>>>>>As the title says, I want to create my own language.
>>>>>I want it to have a similar syntax to Python (but I don't want it to
>>>>>be Python, I have some ideas about it which are surely going to make
>>>>>it incompatible).
>>>>>I want it to be programmed in Lisp.
>>
>>>>What does that mean ? A language is not programmed, compilers or
>>>>interpreters are. But this has nothing to do with the language itself.
>>
>>>There is no need to be so much "dense". You know what I meant.
>>
>>I didn't, and had the same questions. But I think it is just a little
>>ESL confusion. My quess is that you want to implement a new language
>>using Lisp.
>>
>>If so, isn't SICP good on language implementation? And if the language
>>is going to be Lisp-y at least, maybe Lisp in Small Pieces would be useful?
>>
>>I do not really know, last book I read was the Apple II Integer Basic guide.
>>
>>Final thought: Just Do It? If you plan on sexpr notation for your new
>>language you can do it all with macrology.
>>
>>hth,kt
>
>
> What do you think, something like this:
>
>
> class ex2_class in database_variable
>
> my_ex = 7 # initialized property
> my_prop read read_prop write write_prop
>
> def read_prop
> if my_ex > 5
> my_ex
> else
> 0
>
> def write_pop val
> self.my_prop = val
>
> def ex2_class
> print "Constructing ex2_class"
>
> def ex2_class val:integer # declaring val integer
> print "Constructing ex2_class and passed a value of " val
>
> def a_method:string a b # a method that returns the two strings
> a and b concatenated
> a $ b # a and b are now considered strings, so it is equivalent
> to "a:string b:string"
> # argument definition
>
> def a_method a b
> a+b #a and b are integers
>
> def a_method a b
> print a b # for any other case (not string nor integers)
>
>
> The interesting thing would be to make something similar to Allegro
> Cache integrated into this language, so you can create objects which
> can reside both in memory and in a database.
Ah, didn't know we were head for siggy indentation. First thing you do
is write a simple parser to convert to sexprs, then we'll talk again. :)
kt
On 21 oct, 02:06, Kenny <·········@gmail.com> wrote:
> Ah, didn't know we were head for siggy indentation. First thing you do
> is write a simple parser to convert to sexprs, then we'll talk again. :)
Ok, so you recommend me, to use read macros and transform the code
into Lisp instead of creating an interpreter? I also think it is
better, but this leads me to the next question:
How do I manage errors (specially semantic errors, I suppose syntactic
ones are easier)? I make this question because I don't want to hit a
wall when I start to code error management and realize that it is
difficult to translate errors from the Lisp compiler to my
language.. :-S
Javier <·······@gmail.com> writes:
> On 21 oct, 02:06, Kenny <·········@gmail.com> wrote:
>
> > Ah, didn't know we were head for siggy indentation. First thing you do
> > is write a simple parser to convert to sexprs, then we'll talk again. :)
>
> Ok, so you recommend me, to use read macros and transform the code
> into Lisp instead of creating an interpreter?
No. I think the suggestion is to write a parser. Read macros will not
let you dramatically change the the input language. If you really
insist on having an input language radically different from
s-expressions, you will need to write a full-blown parser. That will
also help you with your next phase.
After you write the parser, you will then need to create an interpreter
for your language. The S-expressions just reprsent the parse tree. So,
unless you are just trying to write an alternate syntax for Lisp
(advice: don't bother), you will also need to write an interpreter for
your language.
> I also think it is
> better, but this leads me to the next question:
>
> How do I manage errors (specially semantic errors, I suppose syntactic
> ones are easier)? I make this question because I don't want to hit a
> wall when I start to code error management and realize that it is
> difficult to translate errors from the Lisp compiler to my
> language.. :-S
So, just make sure your parser provides the appropriate annotations in
the parse tree so that you can recover the original program text.
>
>
--
Thomas A. Russ, USC/Information Sciences Institute
Javier wrote:
> On 21 oct, 02:06, Kenny <·········@gmail.com> wrote:
>
>> Ah, didn't know we were head for siggy indentation. First thing you do
>> is write a simple parser to convert to sexprs, then we'll talk again. :)
>
> Ok, so you recommend me, to use read macros and transform the code
> into Lisp instead of creating an interpreter?
No, he didn't say "lisp", he said "s-expr".
(read-strange-languag-from-string "
class ex2_class in database_variable
my_ex = 7 # initialized property
my_prop read read_prop write write_prop
def read_prop
if my_ex > 5
my_ex
else
0
") --> (class ex2-class (database-variable)
(my-ex :initform 7)
(my-prop :reader read-prop :writer write-prop)
(method read-prop ()
(if (> my-ex 5)
my-ex
0)))
> I also think it is
> better, but this leads me to the next question:
>
> How do I manage errors (specially semantic errors, I suppose syntactic
> ones are easier)? I make this question because I don't want to hit a
> wall when I start to code error management and realize that it is
> difficult to translate errors from the Lisp compiler to my
> language.. :-S
Once you have a s-expr, you can start thinking about the interesting
parts of language design: the semantics (including error handling).
The point of this exchange being to signify that there is no point in
defining a barbaric syntax such as:
class ex2_class in database_variable
my_ex = 7 # initialized property
my_prop read read_prop write write_prop
def read_prop
if my_ex > 5
my_ex
else
0
you can directly define a s-expr syntax such as:
(class ex2-class (database-variable)
(my-ex :initform 7)
(my-prop :reader read-prop :writer write-prop)
(method read-prop ()
(if (> my-ex 5)
my-ex
0)))
use the lisp reader to read it, any good lisp editor (such as emacs) to
edit it, and right away start thinking about the interesting bits, the
semantics (and error handling).
Doing so, you may realize that your language is not so different from
Lisp, and that parts of it could be implemented by your compiler or
interpreter as eg. (lambda (my-ex my-prop)
(declare (ignorable my-ex my-prop))
(if (> my-ex 5)
my-ex
0))
and passed directly to lisp, so you only have to work on the semantics
that differ from lisp, instead of implementing everything from scratch.
And if you can add to that a few lisp macros, such as (defmacro class
(name &rest stuff) (generate-lisp-for-strange-language name stuff)),
then you will be able to easily embed your strange language in normal
lisp programs and environments, thus possibly propiciating a better
acceptance (if your semantics have some interest).
--
__Pascal Bourguignon__
http://www.informatimago.com
On 2008-10-20, Javier <·······@gmail.com> wrote:
> What do you think, something like this:
>
>
> class ex2_class in database_variable
>
> my_ex = 7 # initialized property
> my_prop read read_prop write write_prop
>
> def read_prop
> if my_ex > 5
> my_ex
> else
> 0
>
> def write_pop val
> self.my_prop = val
>
> def ex2_class
> print "Constructing ex2_class"
>
> def ex2_class val:integer # declaring val integer
> print "Constructing ex2_class and passed a value of " val
>
> def a_method:string a b # a method that returns the two strings
> a and b concatenated
> a $ b # a and b are now considered strings, so it is equivalent
> to "a:string b:string"
> # argument definition
>
> def a_method a b
> a+b #a and b are integers
>
> def a_method a b
> print a b # for any other case (not string nor integers)
You're looking for this:
(defclass database-variable::ext2-class ()
((my-ex :initform 7)
(my-prop)))
(defmethod read-prop ((obj ext2-class))
(with-slots (my-ex) obj
(if (> my-ex 5) my_ex 0)))
(defmethod initialize-instance ((obj ex2-class) &rest initargs)
(format t "constructing ex2-class object with these arguments: ~s~%"
initargs))
Not sure what your other methods have to do with the class. Catenating strings
doesn't belong here, since it does nothing with the object! Your a_method
doesn't access or update any of the object's properties.
In Lisp, we'd just do this (which is of course quite stupid,
so in actuality we wouldn't do this):
;; combine two objects that are strings: catenation
(defmethod combine-two-objects ((a string) (b string))
(concatenate 'string a b))
;; combine two objects that are numbers: addition
(defmethod combine-two-objects ((a number) (b number))
(+ a b))
;; test
(combine-two-objects "abcd" "efgh") -> "abcdefgh"
(combine-two-objects 1 2) -> 3
Anyway, there is nothing in this example that can't be programmed in normal
Lisp; it does not scream for language extension. Moreover, it looks a lot like
a primitive object system compared to CLOS; a real step backward in object
technology.
You have not invented any new programming language semantics.
> The interesting thing ....
is nowhere to be found in your posting. Thanks for playing.
> would be to make something similar to Allegro
> Cache integrated into this language, so you can create objects which
> can reside both in memory and in a database.
Note that the Allegro Cache does this just fine without a shred of Python
syntax, which is completely irrelevant to the requirement for a persistent
object store.
On 21 oct, 02:50, Kaz Kylheku <········@gmail.com> wrote:
> On 2008-10-20, Javier <·······@gmail.com> wrote:
>
>
>
> > What do you think, something like this:
>
> > class ex2_class in database_variable
>
> > my_ex = 7 # initialized property
> > my_prop read read_prop write write_prop
>
> > def read_prop
> > if my_ex > 5
> > my_ex
> > else
> > 0
>
> > def write_pop val
> > self.my_prop = val
>
> > def ex2_class
> > print "Constructing ex2_class"
>
> > def ex2_class val:integer # declaring val integer
> > print "Constructing ex2_class and passed a value of " val
>
> > def a_method:string a b # a method that returns the two strings
> > a and b concatenated
> > a $ b # a and b are now considered strings, so it is equivalent
> > to "a:string b:string"
> > # argument definition
>
> > def a_method a b
> > a+b #a and b are integers
>
> > def a_method a b
> > print a b # for any other case (not string nor integers)
>
> You're looking for this:
>
> (defclass database-variable::ext2-class ()
> ((my-ex :initform 7)
> (my-prop)))
>
> (defmethod read-prop ((obj ext2-class))
> (with-slots (my-ex) obj
> (if (> my-ex 5) my_ex 0)))
>
> (defmethod initialize-instance ((obj ex2-class) &rest initargs)
> (format t "constructing ex2-class object with these arguments: ~s~%"
> initargs))
>
> Not sure what your other methods have to do with the class. Catenating strings
> doesn't belong here, since it does nothing with the object! Your a_method
> doesn't access or update any of the object's properties.
>
> In Lisp, we'd just do this (which is of course quite stupid,
> so in actuality we wouldn't do this):
>
> ;; combine two objects that are strings: catenation
>
> (defmethod combine-two-objects ((a string) (b string))
> (concatenate 'string a b))
>
> ;; combine two objects that are numbers: addition
>
> (defmethod combine-two-objects ((a number) (b number))
> (+ a b))
>
> ;; test
> (combine-two-objects "abcd" "efgh") -> "abcdefgh"
> (combine-two-objects 1 2) -> 3
>
> Anyway, there is nothing in this example that can't be programmed in normal
> Lisp; it does not scream for language extension. Moreover, it looks a lot like
> a primitive object system compared to CLOS; a real step backward in object
> technology.
>
> You have not invented any new programming language semantics.
>
> > The interesting thing ....
>
> is nowhere to be found in your posting. Thanks for playing.
>
> > would be to make something similar to Allegro
> > Cache integrated into this language, so you can create objects which
> > can reside both in memory and in a database.
>
> Note that the Allegro Cache does this just fine without a shred of Python
> syntax, which is completely irrelevant to the requirement for a persistent
> object store.
You bastard, gilipollas. :-D
I didn't ask you to translate into Lisp that example of what I want
the syntax of my language to be.
I didn't said I was inventing new semantics.
I didn't said that Python syntax is required for persistence.
I said I want to write my own language. If you are not able to
understand it, just shut up.
I bet you to stop publishing stupid responses. Better for your
credibility, if you have one...
Javier <·······@gmail.com> writes:
> I didn't said I was inventing new semantics.
> I didn't said that Python syntax is required for persistence.
>
> I said I want to write my own language. If you are not able to
> understand it, just shut up.
Well, perhaps you should try using Lex, Yacc and C.
But what is the point of writing your own language. Why do you want to
do it instead of using an existing language. What problem do you hope
to solve?
--
Thomas A. Russ, USC/Information Sciences Institute
On Oct 21, 11:07 am, Javier <·······@gmail.com> wrote:
> On 21 oct, 11:36, Ali <·············@gmail.com> wrote:
>
> > Well although you seem a bit rude, I also like indentation, so here's
> > an indentation reader for guile scheme:
>
> >http://srfi.schemers.org/srfi-49/srfi-49.html
>
> > Might need a small amount of changing to run though.
>
> > I've had similar wants for an indentation based lisp, and it's a lot
> > easier if you just change the reader and add some library code. done.
> > Right now I'm a bit stuck at getting mzscheme to use my reader, but
> > after that Lisp will reach the masses and world domination will ensue.
>
> Oh, it's a good start.
> Why did you choose Scheme instead of CL?
a) the reader above is written in Scheme, so easier to get started in
Scheme
b) people are more familiar with lisp-1, I wanted the transition to be
as easy as possible
c) wanted to do something in Scheme, having not used it before
I'd welcome a port to CL when its done. The CL community probably
wouldn't.
Not sure what Kenny's talking about in that post...
The reader will be optional, once people including me learn that
indentation is evil, the reader can be ditched leaving only the evil
imperative library stuff.
Javier <·······@gmail.com> writes:
> I bet you to stop publishing stupid responses. Better for your
> credibility, if you have one...
I bet you will have to stop being so arrogant and abusive if you want to
continue to receive helpful replies from this newsgroup. You are very
close to tripping my threshold for my kill file.
--
Thomas A. Russ, USC/Information Sciences Institute