Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:

  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

'const' binding construct in predicates and preconditions

sebastian_egnersebastian_egner Member Posts: 2
This is a suggestion for a minor addition to the FeatureScript language.

The 'const' binding construct (a.k.a. 'let' in other languages) is extremely helpful for introducing short lived abbreviations in functions. It would be useful to have it available in the predicate language as well.

For a contrived example consider:
{ const x = veryLongVariableName.someFieldNameWhichHasManyCharacters;
  f(x) == [x,x,x]; }
This is a minor addition because there are effective workarounds. You can either define a helper predicate, or use
{ for (var x in [veryLongVariableName.someFieldNameWhichHasManyCharacters])
    f(x) == [x,x,x]; }
which is an implicit way of saying what you mean.

Comments

  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 931
    Thanks for the suggestion.  Just so I understand: do you want to use this primarily in the UI-defining feature preconditions or in non-feature predicates and preconditions?  In other words, would it be enough if const were allowed or would it need to be also a valid part of a UI spec?
    Ilya Baran \ Director, Architecture and FeatureScript \ Onshape Inc
  • sebastian_egnersebastian_egner Member Posts: 2
    Thanks for the suggestion.  Just so I understand: do you want to use this primarily in the UI-defining feature preconditions or in non-feature predicates and preconditions?  In other words, would it be enough if const were allowed or would it need to be also a valid part of a UI spec?
    Hi Ilya,
    I am thinking of the language allowed between curly braces after he 'predicate' and 'precondition' keywords, not after 'annotation'. So I guess that makes it the non-feature predicates and preconditions.

  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 931
    Ok, easy enough.  You should see this in not-too-long (though not the next update).
    Ilya Baran \ Director, Architecture and FeatureScript \ Onshape Inc
Sign In or Register to comment.