Alternative to PUT value INTO variable

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

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2792
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: Alternative to PUT value INTO variable

Post by richmond62 » Mon Mar 31, 2014 4:58 pm

"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.

RickA1
Posts: 13
Joined: Fri Mar 07, 2014 12:31 pm
Location: Brazil

Re: Alternative to PUT value INTO variable

Post by RickA1 » Mon Mar 31, 2014 10:48 pm

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.
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.
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

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: Alternative to PUT value INTO variable

Post by malte » Thu May 01, 2014 11:46 am

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 :-D

Cheers,

Malte

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1812
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Alternative to PUT value INTO variable

Post by [-hh] » Thu May 01, 2014 9:42 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 3:10 pm, edited 1 time in total.
shiftLock happens

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2792
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: Alternative to PUT value INTO variable

Post by richmond62 » Fri May 02, 2014 8:13 am

I think that "main point" is probably better than "big point" :/

pderocco
Posts: 44
Joined: Fri May 16, 2008 1:26 am

Re: Alternative to PUT value INTO variable

Post by pderocco » Tue Sep 18, 2018 7:22 am

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.
Ciao,
Paul

Klaus
Posts: 10486
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Alternative to PUT value INTO variable

Post by Klaus » Tue Sep 18, 2018 11:28 am

Hi Paul,

don't exspect to see this anytime soon in LC!


Best

Klaus

bogs
Posts: 2382
Joined: Sat Feb 25, 2017 10:45 pm

Re: Alternative to PUT value INTO variable

Post by bogs » Tue Sep 18, 2018 3:09 pm

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 :shock:
Image

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2695
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Alternative to PUT value INTO variable

Post by mwieder » Tue Sep 18, 2018 5:52 pm

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

pderocco
Posts: 44
Joined: Fri May 16, 2008 1:26 am

Re: Alternative to PUT value INTO variable

Post by pderocco » Wed Sep 19, 2018 12:53 am

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

Code: Select all

i := j := k := 0
or

Code: Select all

repeat while (i := i - 1) <> 0
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.
Ciao,
Paul

bogs
Posts: 2382
Joined: Sat Feb 25, 2017 10:45 pm

Re: Alternative to PUT value INTO variable

Post by bogs » Mon Sep 24, 2018 6:13 pm

pderocco wrote:
Wed Sep 19, 2018 12:53 am
"put 0 into i" is one of the ugliest things about the LiveCode language.
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 :wink:
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 2792
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria
Contact:

Re: Alternative to PUT value INTO variable

Post by richmond62 » Mon Sep 24, 2018 6:55 pm

one of the ugliest things about the LiveCode language
Let's all get down-and-dirty with subjective statements like that.


FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6236
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Alternative to PUT value INTO variable

Post by FourthWorld » Tue Sep 25, 2018 1:09 am

pderocco wrote:
Wed Sep 19, 2018 12:53 am
...having to say "put 0 into i" is one of the ugliest things about the LiveCode language.
For me the difference between "=" and "==" is one of the ugliest things about a dozen other languages.

De gustibus non est disputandem.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

bogs
Posts: 2382
Joined: Sat Feb 25, 2017 10:45 pm

Re: Alternative to PUT value INTO variable

Post by bogs » Tue Sep 25, 2018 2:58 am

FourthWorld wrote:
Tue Sep 25, 2018 1:09 am
De gustibus non est disputandem.
While that is probably the way it should be, in reality it rarely works out eh :wink:
FourthWorld wrote:
Tue Sep 25, 2018 1:09 am
For me the difference between "=" and "==" is one of the ugliest things about a dozen other languages.
Sure, but if you take that to its ultimate evolution, you get (='.'=), which I'm sure you'd agree is a thing of beauty :D
Image

Post Reply

Return to “Feature Requests”