dsl

Interesting DSLs, Implemented in Scala? [closed]

让人想犯罪 __ 提交于 2019-11-29 23:12:43
I've seen BASIC and Apache Camel DSLs in Scala, and they're just fantastic. Any more examples of such DSLs? You have a good source in the MEAP (Early Access) book DSL in action from Debasish Ghosh (blog: " Ruminations of a programmer ) Testing frameworks like scalatest are classic examples of DSL: test("pop is invoked on an empty stack") { val emptyStack = new Stack[String] evaluating { emptyStack.pop() } should produce [NoSuchElementException] emptyStack should be ('empty) } There are many others DSL-based frameworks out there: specs : "Behaviour-Driven-Design framework" internal DSLs Squeryl

Is something in Swift like LINQ in C#

*爱你&永不变心* 提交于 2019-11-29 20:38:37
I know that Swift is relatively new yet, but I would like to know if Swift have anything like LINQ in C#? With LINQ I mean all the excellent tools like Standard Query Operators , Anonymous types , Object Initializer , etc. Swift incorporates several of the features that are bundled together in .net as LINQ, though possibly not in quite an out-of-the-box sense. Anonymous types are quite close to tuples with named values in Swift. In C#: var person = new { firstName = "John", lastName = "Smith" }; Console.WriteLine(person.lastName); Output: Smith In Swift: var person = (firstName: "John",

DSLs (Domain Specific Languages) in Finance

南楼画角 提交于 2019-11-29 20:31:10
Has anyone worked with DSLs (Domain Specific Languages) in the finance domain? I am planning to introduce some kind of DSL support in the application that I am working on and would like to share some ideas. I am in a stage of identifying which are the most stable domain elements and selecting the features which would be better implemented with the DSL. I have not yet defined the syntax for this first feature. Jay Fields and Obie Fernandez have written and talked extensively on the subject. Jay Fields intro on Domain Specific Languages Jay Fields' series on Business Natural Language Obie

When should I use a Domain Specific Language? [closed]

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 20:22:12
I would like some practical guidance on when I should use a Domain Specific Language . I have found resources about advantages and disadvantages, but what kind of project would warrant its use? It seems like there is a big investment in time to create and maintain a DSL, so in what application space would I get a productivity return on my time investment? Edit: It seems the most common use of DSL is for file formats for persisting data state, what about using a DSL for program logic and structure(perhaps code generation)? When is this feasible? Edit #2 I am mainly asking about when is creating

Are there any Clojure DSLs?

你离开我真会死。 提交于 2019-11-29 20:08:27
Is there any DSL (Domain Specific Language) implemented in Clojure ? fogus Like any Lisp dialect, Clojure draws a very fuzzy line between API and DSL and therefore the term doesn't hold the same mystique that it does in other languages. Lisp programmers tend to write their programs as layers of DSLs, each layer serving those above it. Having said that, here are a few that you could say display non-trivial levels of DSL-ness (in no particular order): Enlive (HTML templating) LazyTest (Unit testing) fnparse (parser generator) Midje (testing & mocking) byte-spec (binary-formats) Vijual (graph

What is a domain specific language? Anybody using it? And in what way?

南笙酒味 提交于 2019-11-29 18:51:00
I guess I am looking for some kind of intro and see if anybody have used it. Are there any particular advantages of using it? Wikipedia: domain-specific language (DSL) is a programming language or specification language dedicated to a particular problem domain, a particular problem representation technique, and/or a particular solution technique. Can anybody give any specific examples of how you have implemented it or how it can be useful in a given scenario? Charlie Martin A domain specific language is a language that's written to deal with a specific domain or set of concerns. There are a

How Pony (ORM) does its tricks?

梦想与她 提交于 2019-11-29 18:35:16
Pony ORM does the nice trick of converting a generator expression into SQL. Example: >>> select(p for p in Person if p.name.startswith('Paul')) .order_by(Person.name)[:2] SELECT "p"."id", "p"."name", "p"."age" FROM "Person" "p" WHERE "p"."name" LIKE "Paul%" ORDER BY "p"."name" LIMIT 2 [Person[3], Person[1]] >>> I know Python has wonderful introspection and metaprogramming builtin, but how this library is able to translate the generator expression without preprocessing? It looks like magic. [update] Blender wrote: Here is the file that you're after. It seems to reconstruct the generator using

Is there a way to write to a text file using Karate

不问归期 提交于 2019-11-29 16:45:10
In my karate tests i need to write response id's to txt files (or any other file format such as JSON), was wondering if it has any capability to do this, I haven't seen otherwise in the documentation. In the case of no, is there a simple JavaScript function to do so? Try karate.write(value, filename) in JavaScript. We have kept this un-documented because we don't encourage it. Also the file will be written only to the current "build" directory which will be target for Maven projects / stand-alone JAR. value can be any data-type. Here is an example . EDIT: for others coming across this answer

Need Groovy syntax help for generating a Closure from a String

六月ゝ 毕业季﹏ 提交于 2019-11-29 15:38:21
I'm trying to generate a closure from a string. The code inside the closure references a DSL function build(). The errors I'm getting imply that Groovy is trying to execute the closure instead of just declaring it. What is the correct syntax for this? Here are some of the constructs I have already tried. sh = new GroovyShell() cl = sh.evaluate( '{ build("my job") }' } => Ambiguous expression could be either a parameterless closure expression or an isolated open code block; sh = new GroovyShell() cl = sh.evaluate( 'L: { build("my job") }' } => No signature of method: Script1.build() is

Scala - URL with Query String Parser and Builder DSL

六眼飞鱼酱① 提交于 2019-11-29 11:21:39
问题 In Scala how do I build up a URL with query string parameters programmatically? Also how can I parse a String containing a URL with query string parameters into a structure that allows me to edit the query string parameters programmatically? 回答1: Spray has a very efficient URI parser. Usage is like so: import spray.http.Uri val uri = Uri("http://example.com/test?param=param") You can set the query params like so: uri withQuery ("param2" -> "2", "param3" -> 3") 回答2: The following library can