tagged mode

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark

Locked
monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

tagged mode

Post by monte » Tue Sep 15, 2015 10:48 pm

Hi

I'm wondering what your thoughts are on making tagged mode available for all scripts. The difference between server and other environments would be the initial state of in_tag rather than the tagged mode itself. By my reckoning this should introduce multi-line script literals e.g.:

Code: Select all

on mouseUp
  put ?>Hello World
 This is a multi-line script literal
 This is another line<?lc
end mouseUp
Cheers

Monte
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: tagged mode

Post by LCMark » Wed Sep 16, 2015 10:23 am

@monte: Am I allowed to say 'blech!'? :)

The tagged mode was there to emulate the PHP-style web site coding practice where code and templates were intertwined. It's certainly a method of coding, but perhaps one which is becoming increasingly less common with all the higher-level web frameworks which have appeared over the last few years thus I'd be concerned about complicating the core language syntax (and the tools that have to process it) to add something which at the moment I'm unclear as to the utility.

Whilst multi-line string constants could be useful in certain instances, I'd prefer we look more deeply into how they might be used and whether there are 'better' abstractions for dealing with those cases. One key problem with multi-line constants is the parsing of them, and ensuring they can actually be used for any string. In this case, for example, you wouldn't be able to have a substring in the text which is '<?lc'. This might sound a bit like nit-picking, but other languages which do have multi-line constants do so in a way so you can choose the terminator - precisely so that there is never any problem in that regard. (Although they all have the problem of being syntactically ugly - but perhaps that isn't something one can do much about).

Actually I wonder whether it needs to be a general 'token' (which could be used anywhere), or whether it could be restricted to some sort of 'nice' constant syntactic block clause - i.e. the ability to declare a string constant over multiple lines which you can then reference as you would any other constant:

Code: Select all

multiline constant kMyLongConstant terminated by "FOOBAR"
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque volutpat,
velit sit amet ultricies pretium, mi felis euismod ligula, ut fringilla lorem felis
in nulla. Proin eleifend dapibus convallis. Curabitur in tortor in dolor hendrerit
blandit id vel diam. Donec vehicula vehicula imperdiet. Nam porta ut dolor eu
feugiat. Integer quis feugiat leo. Proin pellentesque augue eu malesuada
fermentum. Nunc vitae euismod justo, id vulputate mauris. Phasellus tincidunt
enim nulla, vel mattis quam finibus at. Nunc cursus arcu ultricies rutrum
elementum.FOOBAR
end constant
Here the terminated clause is only really needed if none of the lines of your constant start with "end constant".

There are other things to consider here too though - for example indentation and editing in the script editor... I think it is important that any feature such as this still allows nicely formatted readable script.

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: tagged mode

Post by LCMark » Wed Sep 16, 2015 1:18 pm

As has been reminded me today - the multiline string idea with 'terminator' is actually a really bad idea - it mixes up lexical concerns of the language (what constitutes a token) and parsing concerns. This means that such a structure would require all script processing tools to be a lot more complicated. (So I retract that as a viable suggestion :()

peter-b
Posts: 182
Joined: Thu Nov 20, 2014 2:14 pm
Location: LiveCode Ltd.

Re: tagged mode

Post by peter-b » Wed Sep 16, 2015 1:21 pm

My vote is for Python-style multi-line string literals:

Code: Select all

print("""This is a
multi-line
string""")
Mostly because I won't win an argument in favour of Scheme-style multi-line string literals, i.e. any string literal can be multi-line:

Code: Select all

(display "This is a
multi-line
string and it's no big deal")
LiveCode Open Source Team — @PeterTBBrett — peter.brett@livecode.com

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: tagged mode

Post by LCMark » Wed Sep 16, 2015 1:26 pm

Am I allowed to propose escaped strings with string constant elision as a more structured, indentation-friendly, more-reportable-error-friendly approach?

e.g.

Code: Select all

put 'This is an escaped string\n' \
      "This is an unescaped string"
(And yes, I still need to justify why that is more-reportable-error-friendly ;))

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: tagged mode

Post by monte » Wed Sep 16, 2015 2:12 pm

Hehe... just a crazy idea I had while poking in the server to see if I could use it to for the atom linter instead of the standalone engine so it could lint server files too.

I thing we had a long discussion about escaped strings a couple of years ago.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Locked

Return to “Engine Contributors”