Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: SetWidget syntax change + enhancement #1610

Closed
felixhayashi opened this issue Mar 23, 2015 · 9 comments
Closed

Proposal: SetWidget syntax change + enhancement #1610

felixhayashi opened this issue Mar 23, 2015 · 9 comments

Comments

@felixhayashi
Copy link
Contributor

It is very(!!) annoying to set multiple variables as it spams the code.

<$set name="key1" value="val1" />
<$set name="key2" value={{!!fieldxy}} />
<$set name="key3" value={{!!bla}} />
....
</$set>
</$set>
</$set>

Would something like the following be possible (e.g. like it already exists for the set field widget or the send message widget)

<$set key1="val1" key2={{!!fieldxy}} key3={{!!bla}} />
....
</$set>

I know that this new syntax would mean that keys "name" and "value" would be misinterpreted and break backwards compatibility.

Therefore we could either treat "name" and "value" specially or introduce a new set widget to the core called e.g. "<$multi-set" or "<$xset" or something like this.

Thanks
-Felix

@felixhayashi felixhayashi changed the title Proposal Set widget syntax change + enhancement Proposal: Set widget syntax change + enhancement Mar 23, 2015
@felixhayashi felixhayashi changed the title Proposal: Set widget syntax change + enhancement Proposal: SetWidget syntax change + enhancement Mar 23, 2015
@Jermolene
Copy link
Member

Hi @felixhayashi as you've noted, the backwards compatibility problem with the proposal is the ambiguity with the existing syntax.

A backwards compatible version of the proposal might be:

<$set $key1="val1" $key2={{!!fieldxy}} $key3={{!!bla}} />
....
</$set>

It's annoyingly inconsistent with other widget usage of the $ prefix, but it is at least backwards compatible.

The other option of implementing the widget under a different name is attractive, except that I don't think we've got a good enough name yet - <$multi-set> is my favourite so far, but it's not easy to type. I did wonder about using <$let> but I think it's too confusingly similar.

@felixhayashi
Copy link
Contributor Author

Hi @Jermolene

thanks for responding on this.

It's annoyingly inconsistent with other widget usage of the $ prefix, but it is at least backwards compatible.

I agree, people will confuse/forget when to use the $ and when not.

<$multi-set> is my favourite so far, but it's not easy to type.

Good point, a key widget like $set should be easy to type. The idea of using let is truly appealing as (1) it shows the close relation to set, (2) fast to type (3) is used in other languages to define a constant which is also fine for our case and (4) the letter "l" is far away from "s" on euro-keyboards so it cannot be confused.

<$let> but I think it's too confusingly similar.

I think it is a plus that they sound similar. Set is clearly documented so I think the risk that somebody confuses let with the former set is minimal and does not compete with the advantages of the term mentioned above.

If you still do not like "let" what about

<$mset
<$vars
<$bind
<$prop

-Felix

@Jermolene
Copy link
Member

Hmm <$var is good, how about <$vars to make clearer that multiple variables are being set?

@felixhayashi
Copy link
Contributor Author

Hmm <$var is good, how about <$vars to make clearer that multiple variables are being set?

Hehe, a second before you commented, I had the same thought and edited my post - so yes, I agree on that ;)

@felixhayashi
Copy link
Contributor Author

Should I do a pull request or do you want to handle this?

@Jermolene
Copy link
Member

Please do go ahead with a pull request - I'll merge after 5.1.8 is out.

@felixhayashi
Copy link
Contributor Author

ok

felixhayashi added a commit to felixhayashi/TiddlyWiki5 that referenced this issue Apr 26, 2015
It thereby reduces code complexity that would arise when setting
many variables using "<$set>".

```
\define helloworld() Hello world!
<$vars greeting="Hi" me={{!!title}} sentence=<<helloworld>>>
  <<greeting>>! I am <<me>> and I say: <<sentence>>
</$vars>
```

How this Widget differs from the set widget:

 * Variables may be created by using the "key=value" notation
   that you already know from widgets like action-setfield.
 * You cannot specify a fallback ("emptyValue")
 * You cannot use a filter to produce a conditional variable assignement

Original discussion that led to the creation of this widget:
TiddlyWiki#1610
@felixhayashi
Copy link
Contributor Author

Hi @Jermolene

I now created the corresponding pull request.

-Felix

felixhayashi added a commit to felixhayashi/TiddlyWiki5 that referenced this issue Apr 26, 2015
It thereby reduces code complexity that would arise when setting
many variables using "<$set>".

```
\define helloworld() Hello world!
<$vars greeting="Hi" me={{!!title}} sentence=<<helloworld>>>
  <<greeting>>! I am <<me>> and I say: <<sentence>>
</$vars>
```

How this Widget differs from the set widget:

 * Variables may be created by using the "key=value" notation
   that you already know from widgets like action-setfield.
 * You cannot specify a fallback ("emptyValue")
 * You cannot use a filter to produce a conditional variable assignement

Original discussion that led to the creation of this widget:
TiddlyWiki#1610
@felixhayashi
Copy link
Contributor Author

@Jermolene

I also included a widget description for the tiddlywiki.com docs in this pull request.

-Felix

felixhayashi added a commit to felixhayashi/TiddlyWiki5 that referenced this issue Apr 26, 2015
It thereby reduces code complexity that would arise when setting
many variables using "<$set>".

```
\define helloworld() Hello world!
<$vars greeting="Hi" me={{!!title}} sentence=<<helloworld>>>
  <<greeting>>! I am <<me>> and I say: <<sentence>>
</$vars>
```

How this Widget differs from the set widget:

 * Variables may be created by using the "key=value" notation
   that you already know from widgets like action-setfield.
 * You cannot specify a fallback ("emptyValue")
 * You cannot use a filter to produce a conditional variable assignement

Original discussion that led to the creation of this widget:
TiddlyWiki#1610
felixhayashi added a commit to felixhayashi/TiddlyWiki5 that referenced this issue Apr 27, 2015
It thereby reduces code complexity that would arise when setting
many variables using "<$set>".

```
\define helloworld() Hello world!
<$vars greeting="Hi" me={{!!title}} sentence=<<helloworld>>>
  <<greeting>>! I am <<me>> and I say: <<sentence>>
</$vars>
```

How this Widget differs from the set widget:

 * Variables may be created by using the "key=value" notation
   that you already know from widgets like action-setfield.
 * You cannot specify a fallback ("emptyValue")
 * You cannot use a filter to produce a conditional variable assignement

Original discussion that led to the creation of this widget:
TiddlyWiki#1610
felixhayashi added a commit to felixhayashi/TiddlyWiki5 that referenced this issue Apr 27, 2015
It thereby reduces code complexity that would arise when setting
many variables using "<$set>".

```
\define helloworld() Hello world!
<$vars greeting="Hi" me={{!!title}} sentence=<<helloworld>>>
  <<greeting>>! I am <<me>> and I say: <<sentence>>
</$vars>
```

How this Widget differs from the set widget:

 * Variables may be created by using the "key=value" notation
   that you already know from widgets like action-setfield.
 * You cannot specify a fallback ("emptyValue")
 * You cannot use a filter to produce a conditional variable assignement

Original discussion that led to the creation of this widget:
TiddlyWiki#1610
felixhayashi added a commit to felixhayashi/TiddlyWiki5 that referenced this issue Apr 27, 2015
It thereby reduces code complexity that would arise when setting
many variables using "<$set>".

```
\define helloworld() Hello world!
<$vars greeting="Hi" me={{!!title}} sentence=<<helloworld>>>
  <<greeting>>! I am <<me>> and I say: <<sentence>>
</$vars>
```

How this Widget differs from the set widget:

 * Variables may be created by using the "key=value" notation
   that you already know from widgets like action-setfield.
 * You cannot specify a fallback ("emptyValue")
 * You cannot use a filter to produce a conditional variable assignement

Original discussion that led to the creation of this widget:
TiddlyWiki#1610
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants