Wiki

Ticket #42 (assigned enhancement)

Opened 16 years ago

Last modified 15 years ago

Provide platform independent line terminator metacharacter in strings

Reported by: hopscc Owned by: Chuck
Priority: medium Milestone: Cobra 0.9
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:

Description

Provide a metacharacter in strings that generates the correct line terminator string for the platform being run on.
(Analogous to \t for tab, etc)

See discusssion  Platform independent line terminators

Attachments

stringTermin1.patch Download (1.7 KB) - added by hopscc 16 years ago.
string-termin2.cobra Download (3.0 KB) - added by hopscc 15 years ago.
string-termin2.patch Download (3.1 KB) - added by hopscc 15 years ago.

Change History

Changed 16 years ago by hopscc

Changed 16 years ago by hopscc

  • status changed from new to assigned
  • owner set to Chuck

patch for \N emitting Environment.newLine.
Commented lines for alternative \N emitting newline and \n emitting environment.newLine
(but if used will need to change test file 100-basics/068-string-termin.cobra)

Changed 16 years ago by Chuck

  • milestone set to Cobra 0.9

Changed 15 years ago by hopscc

How to do currently gets a specific wiki description

OTOH theres a (almost due for its first birthday) patch for that ....

# current 
def visitMessage(url) as String
    nl = CobraCore.newLine
    sb = StringBuilder()
    sb.append('Hello [.name],[nl]')
    sb.append('Please visit [ur].[nl]')
    return sb.toString

vs

# \N maps to platform nl string (CobraCore.newline)
def visitMessage(url) as String
    sb = StringBuilder()
    sb.append('Hello [.name],\N')
    sb.append('Please visit [ur].\N')
    return sb.toString

or even

# \n maps to *platform* newline string, \N (or something else) maps to nl 
def visitMessage(url) as String
    sb = StringBuilder()
    sb.append('Hello [.name],\n')
    sb.append('Please visit [ur].\n')
    return sb.toString

... touch to raise back into last 50 updates....

Changed 15 years ago by Chuck

  • owner changed from Chuck to hopscc

I was going to apply this tonight as \N for the platform newline, but in the patch I see that it is evaluated at compile-time. This means that if I build a Cobra program on .NET and bring it over to Mono on Mac or Linux, it will behave incorrectly, which is different from using CobraCore.newLine (or Environment.newLine). If you can make it adapt at run-time and no less efficient than using a .newLine call explicitly, then I can accept.

Changed 15 years ago by hopscc

Changed 15 years ago by hopscc

  • owner changed from hopscc to Chuck

probably all of uncommon, unnecessary and undesirable (and another LARAI)

but
Heres another patch
it has exactly the same execution profile as doing the substitution explicitly.
I eagerly await the changeset.

Changed 15 years ago by hopscc

Note: See TracTickets for help on using tickets.