• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Eliminating Parenthesis within custom internal DSL

 
Greenhorn
Posts: 22
Scala IntelliJ IDE Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm trying to write a simple temperature conversion DSL for learning purposes.
Here is my code so far:

Temperature.scala

TemperatureScale.scala

TestTemperature.scala

I think I did pretty ok for a first attempt, but I would like to eliminate the need for the extra parenthesis if possible, so that I could use the DSL like this:

Is that possible? If so, could you guys please point the way?

Cheers
 
Ranch Hand
Posts: 72
Scala Monad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can avoid paranthesis using this calling notation:



This is also quiet not looking natural. We can improve this further:

Adding another method in class Temperature:



with this method in 'Temperature' class, we can call like this:




- Marimuthu Madasamy
 
reply
    Bookmark Topic Watch Topic
  • New Topic