Forum: Ruby-core [ruby-trunk - Feature #7309][Open] HEREDOC end of line or similar

Posted by eTM (Juergen Mangler) (Guest)
on 2012-11-08 11:21
(Received via mailing list)
Issue #7309 has been reported by eTM (Juergen Mangler).

----------------------------------------
Feature #7309: HEREDOC end of line or similar
https://bugs.ruby-lang.org/issues/7309

Author: eTM (Juergen Mangler)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:


example: writing a dsl that expresses some facts

      increase "coding" experience one level until 'next summer'

This can right now be done in different ways

* make the whole thing a string and parse it
* increase.experience('coding').one_level.until('next summer')
* increase "'coding' experience one level until 'next summer'"

Another nice alternative would be a heredoc type that operates to the 
end of the line (i couldn't find existing implementations for perl and 
ruby)

      Example1: increase <<* "coding" experience one level until "next 
summer"
      Example2: increase <<< "coding" experience one level until "next 
summer"

      def increase(str) # the rest of the line is passed as a string

Although it looks not very elegant for a DSL it would to the job. of 
course something more unobtrusive would be better, but i don't know how 
difficult this would be for the parser. e.g.:

      def increase(~str); end

* When a method has ~ attribute it could automatically read the rest of 
the line as string when invoked (or when used with method call brackets 
to the closing bracket). Invoke like:

      increase "coding" experience one level until "next summer"

OR

      increase("coding" experience one level until "next summer")

* ~ attributes always as last attribute: def increase(a,b,~str); end
** Invoke like: increase "val1", "val2", the rest is a string
** In this case the rest str should have a leading " "

-------

Summary: First possibility (heredoc like) would allow for neat(er) 
looking dsl's. The second possibility (~attributes, not sure if this is 
doable) would allow for a VERY neat looking DSL's. Both for sure also 
would increase the interest in string parsing ;-)
Posted by boris_stitnicky (Boris Stitnicky) (Guest)
on 2012-11-18 05:27
(Received via mailing list)
Issue #7309 has been updated by boris_stitnicky (Boris Stitnicky).


In other words, you want to mangle Ruby syntax :-)
----------------------------------------
Feature #7309: HEREDOC end of line or similar
https://bugs.ruby-lang.org/issues/7309#change-33048

Author: eTM (Juergen Mangler)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:


example: writing a dsl that expresses some facts

      increase "coding" experience one level until 'next summer'

This can right now be done in different ways

* make the whole thing a string and parse it
* increase.experience('coding').one_level.until('next summer')
* increase "'coding' experience one level until 'next summer'"

Another nice alternative would be a heredoc type that operates to the 
end of the line (i couldn't find existing implementations for perl and 
ruby)

      Example1: increase <<* "coding" experience one level until "next 
summer"
      Example2: increase <<< "coding" experience one level until "next 
summer"

      def increase(str) # the rest of the line is passed as a string

Although it looks not very elegant for a DSL it would to the job. of 
course something more unobtrusive would be better, but i don't know how 
difficult this would be for the parser. e.g.:

      def increase(~str); end

* When a method has ~ attribute it could automatically read the rest of 
the line as string when invoked (or when used with method call brackets 
to the closing bracket). Invoke like:

      increase "coding" experience one level until "next summer"

OR

      increase("coding" experience one level until "next summer")

* ~ attributes always as last attribute: def increase(a,b,~str); end
** Invoke like: increase "val1", "val2", the rest is a string
** In this case the rest str should have a leading " "

-------

Summary: First possibility (heredoc like) would allow for neat(er) 
looking dsl's. The second possibility (~attributes, not sure if this is 
doable) would allow for a VERY neat looking DSL's. Both for sure also 
would increase the interest in string parsing ;-)
Posted by mame (Yusuke Endoh) (Guest)
on 2012-11-24 02:57
(Received via mailing list)
Issue #7309 has been updated by mame (Yusuke Endoh).

Status changed from Open to Assigned
Assignee set to matz (Yukihiro Matsumoto)
Target version set to next minor


----------------------------------------
Feature #7309: HEREDOC end of line or similar
https://bugs.ruby-lang.org/issues/7309#change-33725

Author: eTM (Juergen Mangler)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category:
Target version: next minor


example: writing a dsl that expresses some facts

      increase "coding" experience one level until 'next summer'

This can right now be done in different ways

* make the whole thing a string and parse it
* increase.experience('coding').one_level.until('next summer')
* increase "'coding' experience one level until 'next summer'"

Another nice alternative would be a heredoc type that operates to the 
end of the line (i couldn't find existing implementations for perl and 
ruby)

      Example1: increase <<* "coding" experience one level until "next 
summer"
      Example2: increase <<< "coding" experience one level until "next 
summer"

      def increase(str) # the rest of the line is passed as a string

Although it looks not very elegant for a DSL it would to the job. of 
course something more unobtrusive would be better, but i don't know how 
difficult this would be for the parser. e.g.:

      def increase(~str); end

* When a method has ~ attribute it could automatically read the rest of 
the line as string when invoked (or when used with method call brackets 
to the closing bracket). Invoke like:

      increase "coding" experience one level until "next summer"

OR

      increase("coding" experience one level until "next summer")

* ~ attributes always as last attribute: def increase(a,b,~str); end
** Invoke like: increase "val1", "val2", the rest is a string
** In this case the rest str should have a leading " "

-------

Summary: First possibility (heredoc like) would allow for neat(er) 
looking dsl's. The second possibility (~attributes, not sure if this is 
doable) would allow for a VERY neat looking DSL's. Both for sure also 
would increase the interest in string parsing ;-)
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.