Half Strict Compilation mode

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderator: Klaus

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Half Strict Compilation mode

Post by BarrySumpter » Thu Aug 04, 2011 3:17 am

I'm pretty sure field is a keyword for the compiler.

Here isn't tFldName a local/temporary variable?
put "CustomerName" into tFldname
Or does the compiler know that tFldnameis an object and I don't need to type cast?
Can you have a local variable name with spaces?


Again, my practice is Not to use spaces in field names ever.
And not Need to use "" around names.
the space is an extra key stroke.
The " is two key strokes.
Totaling to 5 keystrokes at least extra per name.
Again, we're measuring the difference in micro-seconds of execution speed.


And here fRlfName is a control object?
put "Milo Fenderbender" into field tFldname
Where spaces in control names are allowed.

It was just a thought.
I don't know enough about the language and all its incredible variations.
But I can see in my head it could be ticked on to insert ""
with the "" highlighted for replacement.
and if a delete key is NOT pressed then the entry would begin inside the "|".
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Half Strict Compilation mode

Post by mwieder » Thu Aug 04, 2011 4:33 am

Ah. I start to see where you're going with this...
No,

Code: Select all

put "Milo Fenderbender" into field tFldName
in this example puts the string "Milo Fenderbender" into field "CustomerName" since we've already put "CustomerName" into the variable tFldName. The "put" isn't assigning a name to the field, it's storing a value into the field.

I never use spaces in object names. You can do it, but I think it's Bad Practice. And I don't think you can get away with space in variable names, although I haven't ever tried it. There are many syntactical obstacles to assigning quotes automatically because the language is so rich and supports so many variations.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Half Strict Compilation mode

Post by BarrySumpter » Thu Aug 04, 2011 4:59 am

Yep gotcha, I read that as two examples of your point and not one point with two script lines. My bad.
That situation solved with my "" selected idea.

Code: Select all

I never use spaces in object names. You can do it, but I think it's Bad Practice.
Agreed. Well for me anyway. If others wanna then no prob.
And I don't think you can get away with space in variable names, although I haven't ever tried it.
Just tried

Code: Select all

Local "my xxx Var"
Wouldn't compile. I though that might be where we were headed.

Code: Select all

There are many syntactical obstacles to assigning quotes automatically because the language is so rich and supports so many variations.
Yeah fair enough.
Hoping my "" selected idea will tilt the balance enough to have a go.
Even though I will probably never use it. LOL
Last edited by BarrySumpter on Thu Aug 04, 2011 5:21 am, edited 1 time in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Half Strict Compilation mode

Post by mwieder » Thu Aug 04, 2011 5:14 am

Here's what I usually do. This saves a lot of typing quotes and also cuts down on typo errors, which are especially prone to occur in quoted strings:

constant kFldName= "CustomerName"
constant kFldAmount= "InvoiceAmount"

put "hello, bucko" into field kFldName
put tInvoiceTotal into field kFldAmount
...

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Half Strict Compilation mode

Post by BarrySumpter » Thu Aug 04, 2011 5:20 am

Hey! Hey! Hey!
Very cool. As yet another idea I would never have tried.

If that saves the milisecond execution time?

If not then why not just use:

Code: Select all

put "hello, bucko" into field lblCustomerName
put tInvoiceTotal into field txtInvoiceAmount
i.e. without the constant dimentioning.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Half Strict Compilation mode

Post by mwieder » Thu Aug 04, 2011 11:25 pm

Barry-

It's not so much that it saves execution time, but more that it a) saves error-prone typing and b) allows you change the name of a control in one place without having to search through your code for all the places you used it. I didn't put a lot of example stuff in the previous post, but I'd normally do this if I'm access a control more than a couple of times. If I have a script that needs a given field name a dozen times or so (and I do) it's much more convenient to have it in a constant declaration than to have to specify a quoted field name a dozen times and maybe end up with a typo or three.

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Half Strict Compilation mode

Post by BarrySumpter » Thu Aug 04, 2011 11:51 pm

Fair enough.

I'd use find/replace.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Half Strict Compilation mode

Post by jacque » Fri Aug 05, 2011 12:06 am

mwieder wrote: I never use spaces in object names.
Me either. At least, not until Bill Marriott mentioned the convenience of using a number at the end of names as a counter or identifier in certain situations. That way you don't have to parse the end of the name looking for a number, you can just grab the last word of the name. I still use one-word field names mostly, but one time I found this technique is useful.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply