[scala] use scala to make a custom language

View: New views
8 Messages — Rating Filter:   Alert me  

[scala] use scala to make a custom language

by frapas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm total new to Scala.
It seems a very interesting language.
 
I'm interested in the possibility to use Scala features (like implicit conversions, operators as method ecc.) to create a custom programming language.
 
I think that the impossibility to specify operator precedence/associativity could be an obstacle.
 
I'm, for example, interested in the possibility to create a language with syntax similar to perl6.
 
The operators are:
in particular:
  ~ string concatenation (coerce numbers to string)
  ~~ for regexp (through external library, I know Scala has not regexp)
  math operator (+-*/ ecc ) coerce strings to numbers
 
 
Do you think it's possible ?
 
Is there any prevision to allow full control of operators (precedence, associativity ecc ecc ) ?
 

Re: [scala] use scala to make a custom language

by Landei :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


frapas wrote:
I think that the impossibility to specify operator precedence/associativity
could be an obstacle.
yes
I'm, for example, interested in the possibility to create a language with
syntax similar to perl6.

The operators are:
http://dev.perl.org/perl6/doc/design/syn/S03.html
in particular:
  ~ string concatenation (coerce numbers to string)
  ~~ for regexp (through external library, I know Scala has not regexp)
  math operator (+-*/ ecc ) coerce strings to numbers

Do you think it's possible ?
I think you have to make some compromises :-)

There was a good article about operators at Code Commit:
http://www.codecommit.com/blog/scala/implementing-groovys-elvis-operator-in-scala


Re: [scala] use scala to make a custom language

by frapas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Jul 8, 2008 at 8:38 AM, Landei <Daniel.Gronau@...> wrote:
 
frapas wrote:
>
> I think that the impossibility to specify operator
> precedence/associativity
> could be an obstacle.
>
yes
 
I hope this will be implemented in future Scala releases.
Any prevision ?
It could be a great feature and with the ability to implement foreign languages syntax  in Scala it will be easiest to port chunk of code and library from different languages to Scala.
 


> I'm, for example, interested in the possibility to create a language with
> syntax similar to perl6.
>
> The operators are:
> http://dev.perl.org/perl6/doc/design/syn/S03.html
> in particular:
>   ~ string concatenation (coerce numbers to string)
>   ~~ for regexp (through external library, I know Scala has not regexp)
>   math operator (+-*/ ecc ) coerce strings to numbers
>
> Do you think it's possible ?
>
I think you have to make some compromises :-)

There was a good article about operators at Code Commit:
http://www.codecommit.com/blog/scala/implementing-groovys-elvis-operator-in-scala
Very interesting !
thanks
 
Francesco

Re: [scala] use scala to make a custom language

by Sean McDirmid :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I doubt that custom precedence would ever come to Scala. That would
require syntactic level configurability based on the type of a symbol,
and most language people wouldn't dare to mix type checking with
parsing, its probably not a good idea. (The exception being C++, but I
think they do something hacky to avoid that).

On Tue, Jul 8, 2008 at 4:55 PM, Francesco Pasqualini <frapas@...> wrote:

> I hope this will be implemented in future Scala releases.
> Any prevision ?
> It could be a great feature and with the ability to implement foreign
> languages syntax  in Scala it will be easiest to port chunk of code and
> library from different languages to Scala.

Re: [scala] use scala to make a custom language

by frapas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

... I understand.
But IMHO, without custom precedence, the ability to create/overoad operators is less useful.

Francesco


On Tue, Jul 8, 2008 at 11:22 AM, Sean McDirmid <sean.mcdirmid@...> wrote:
I doubt that custom precedence would ever come to Scala. That would
require syntactic level configurability based on the type of a symbol,
and most language people wouldn't dare to mix type checking with
parsing, its probably not a good idea. (The exception being C++, but I
think they do something hacky to avoid that).

On Tue, Jul 8, 2008 at 4:55 PM, Francesco Pasqualini <frapas@...> wrote:

> I hope this will be implemented in future Scala releases.
> Any prevision ?
> It could be a great feature and with the ability to implement foreign
> languages syntax  in Scala it will be easiest to port chunk of code and
> library from different languages to Scala.


Re: [scala] use scala to make a custom language

by Christos KK Loverdos :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Tue, Jul 8, 2008 at 12:47 PM, Francesco Pasqualini <frapas@...> wrote:
... I understand.
But IMHO, without custom precedence, the ability to create/overoad operators is less useful.

Not at all. It brings discipline. (note that I would like custom precedence too, though....)

--
__~O
-\ <, Christos KK Loverdos
(*)/ (*) http://ckkloverdos.com

Re: [scala] use scala to make a custom language

by Ricky Clarkson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

"brings discipline" must mean "there are arbitrary rules to follow" then.  Please, for discipline, start writing Java code with labels containing line numbers:

_10: System.out.println("Hello");
_20: etc.

2008/7/8 Christos KK Loverdos <loverdos@...>:


On Tue, Jul 8, 2008 at 12:47 PM, Francesco Pasqualini <frapas@...> wrote:
... I understand.
But IMHO, without custom precedence, the ability to create/overoad operators is less useful.

Not at all. It brings discipline. (note that I would like custom precedence too, though....)

--
__~O
-\ <, Christos KK Loverdos
(*)/ (*) http://ckkloverdos.com


Re: [scala] use scala to make a custom language

by Christos KK Loverdos :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hahaha... good :-)



On Tue, Jul 8, 2008 at 1:50 PM, Ricky Clarkson <ricky.clarkson@...> wrote:
"brings discipline" must mean "there are arbitrary rules to follow" then.  Please, for discipline, start writing Java code with labels containing line numbers:

_10: System.out.println("Hello");
_20: etc.

2008/7/8 Christos KK Loverdos <loverdos@...>:



On Tue, Jul 8, 2008 at 12:47 PM, Francesco Pasqualini <frapas@...> wrote:
... I understand.
But IMHO, without custom precedence, the ability to create/overoad operators is less useful.

Not at all. It brings discipline. (note that I would like custom precedence too, though....)

--
__~O
-\ <, Christos KK Loverdos
(*)/ (*) http://ckkloverdos.com




--
__~O
-\ <, Christos KK Loverdos
(*)/ (*) http://ckkloverdos.com
LightInTheBox - Buy quality products at wholesale price