Alternative to PUT value INTO variable
Moderator: Klaus
-
- Livecode Opensource Backer
- Posts: 10080
- Joined: Fri Feb 19, 2010 10:17 am
Re: Alternative to PUT value INTO variable
"No one is proposing to remove PUT, just create an alternative shortcut syntax allowing people to choose."
Right: gottit.
Still not all that keen on it as I wonder if it wouldn't just obfuscate things.
Right: gottit.
Still not all that keen on it as I wonder if it wouldn't just obfuscate things.
Re: Alternative to PUT value INTO variable
I'm sure both are clear about the meaning. I feel the opposed, the proposal makes it more clear. But as I FEEL one way, you FEEL differently.richmond62 wrote:"No one is proposing to remove PUT, just create an alternative shortcut syntax allowing people to choose."
Right: gottit.
Still not all that keen on it as I wonder if it wouldn't just obfuscate things.
Some people will feel like you, and some, math oriented lazy people, like me. There is no wrong way here.
Probably the first one works better for the language oriented person, and the last one for the math oriented person.
PUT 4 * x INTO t1
PUT t1 / 3 INTO t2
PUT random(255) INTO rnd1
SET t1 = 4 * x,
t2 = t1 / 3,
rnd1 = random(255)
PUT inc(inc1) INTO inc1 -- up
PUT dec(dec1) INTO dec1 -- down
SET inc1 = inc(inc1), dec1 = dec(dec1) -- up/down
Re: Alternative to PUT value INTO variable
For the multiline version of set, I would miss an end SET. With SET being a shorter alternative to put into I would not have too much of a problem. I might even want to adopt it, as it would avoid having stray puts all over the place
Cheers,
Malte

Cheers,
Malte
Re: Alternative to PUT value INTO variable
..........
Last edited by [-hh] on Wed Aug 13, 2014 3:10 pm, edited 1 time in total.
shiftLock happens
-
- Livecode Opensource Backer
- Posts: 10080
- Joined: Fri Feb 19, 2010 10:17 am
Re: Alternative to PUT value INTO variable
I think that "main point" is probably better than "big point" :/
Re: Alternative to PUT value INTO variable
I was going to suggest this, but found this old thread. I'd like to see support for a simple "x = expr" syntax, interpreted as an assignment if it's not in the middle of an expression where it could be a boolean. The main reason is that a lot of us probably code in other languages besides LiveCode, and we find ourselves typing that without thinking, getting an error, and having to fix it.
It would be nice if you could put "lvalue" chunk expressions to the left of the equals sign, although it might simplify the parser if they had to be parenthesized.
It would be nice if you could put "lvalue" chunk expressions to the left of the equals sign, although it might simplify the parser if they had to be parenthesized.
Ciao,
Paul
Paul
Re: Alternative to PUT value INTO variable
Hi Paul,
don't exspect to see this anytime soon in LC!
Best
Klaus
don't exspect to see this anytime soon in LC!
Best
Klaus
Re: Alternative to PUT value INTO variable
I wouldn't expect to see this ever, as the convention your using is closer to using a language other than an xcode language as has been pointed out earlier.
Aside from that, though, I can't even begin to picture the train-wrecks that would happen to you bringing past code up the ladder to newer IDEs
Aside from that, though, I can't even begin to picture the train-wrecks that would happen to you bringing past code up the ladder to newer IDEs


Re: Alternative to PUT value INTO variable
If you want to monkeypatch your own preprocessor into the script editor, here's the code to handle the conversion. The works well for script-only stacks because you can write the code in a text file with a normal text editor, then run the conversion in memory so that the LC compiler doesn't choke. YMMV.
Code: Select all
# process "normal" variable assignment
# x = 3
# if x == 3 then
# if x != 3 then
local txCode, tSavedDelimiter
put the itemDelimiter into tSavedDelimiter
set the itemDelimiter to "="
repeat for each line tLine in tScript
switch word 1 of tLine
case "constant"
break
case "if"
replace "==" with "is" in tLine
replace "!=" with "is not" in tLine
case "repeat"
case "put"
break
default
# assignments
if "=" is among the tokens of tLine then
put "put" && item 2 of tLine && "into" && item 1 of tLine into tLine
end if
end switch
put tLine & cr after txCode
end repeat
set the itemDelimiter to tSavedDelimiter
put txCode into tScript
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: Alternative to PUT value INTO variable
Another possibility is to use a different operator, like := used in Algol and Pascal. Then, it could be made part of the expression syntax, so one could write or
Sure, it's different from what LiveCode is now, but having to say "put 0 into i" is one of the ugliest things about the LiveCode language.
Code: Select all
i := j := k := 0
Code: Select all
repeat while (i := i - 1) <> 0
Ciao,
Paul
Paul
Re: Alternative to PUT value INTO variable
I would say beauty is in the eye of the beholder. I came here from standard (and not so standard) languages, I rather like the way this language flows now that I have gotten used to it.
When I first started using it, my thinking was more like yours. Of course, if they started changing all the conventions to be like every other language, what would be the point to using this one?
I might add that if you really like pascal, then use pascal (I still do on occaision), but don't try to change Lc into pascal, not only would you break the heck out of stuff, it is pointless since there already is a pascal


-
- Livecode Opensource Backer
- Posts: 10080
- Joined: Fri Feb 19, 2010 10:17 am
Re: Alternative to PUT value INTO variable
Let's all get down-and-dirty with subjective statements like that.one of the ugliest things about the LiveCode language
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Alternative to PUT value INTO variable
For me the difference between "=" and "==" is one of the ugliest things about a dozen other languages.
De gustibus non est disputandem.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Alternative to PUT value INTO variable
While that is probably the way it should be, in reality it rarely works out eh

Sure, but if you take that to its ultimate evolution, you get (='.'=), which I'm sure you'd agree is a thing of beautyFourthWorld wrote: ↑Tue Sep 25, 2018 1:09 amFor me the difference between "=" and "==" is one of the ugliest things about a dozen other languages.

