MATLAB Answers

0

When will MABLAB allow users to use Greek letters as symbolic variables? This is very frustrating being a physicist as Greek are just about as common as English letters. This would satisfy a lot of people.

Asked by Jackson Kock on 15 Sep 2018 at 0:44
Latest activity Commented on by Walter Roberson
on 17 Sep 2018 at 3:30

Question says it all.

  18 Comments

But the first has some implications in it that aren't true afaict. It shows supposed C++ code

"After the statement Σ = 0,..."

but there's no indication such code actually compiled, but just a postulated case where the subsequent argument is whether a lowercase sigma should or should not be the same sigma (parenthetically, that seems obvious, C/C++ like ML are case-sensitive so they're obviously two different variables if they were valid at all).

However, in the 2017 C++ Standard identifiers are

5.10  Identifiers
identifier:
  identifier-nondigit
  identifier identifier-nondigit
  identifier digit
identifier-nondigit:
  nondigit
  universal-character-name
nondigit: one of
  a b c d e f g h i j k l m
  n o p q r s t u v w x y z
  A B C D E F G H I J K L M
  N O P Q R S T U V W X Y Z _
digit: one of
  0 1 2 3 4 5 6 7 8 9
...

Followed by the following footnote:

1) An identifier is an arbitrarily long sequence of letters and digits. ... The initial element shall not be a universal-character-name ...

IOW, while one can build variable names with unicode (and actually I just learned that; I had looked only at summary syntax rules before, not the actual Standard which didn't incorporate unicode just the standard rules of nonnumeric first, etc., ...), the OP couldn't use just a single Greek letter alpha as a variable name but would have to at least prefix it w/ an underscore or other valid nondigit. (*)

I'd guess Java probably also has similar rules?

My comment on feasibility to implement simply implied it shouldn't be hard to parse a unicode character and imbed it as found in the source; the comments on disadvantages in the reference link mostly relate to readability of the result or other presentation issues, not whether the compiler could just blindly insert the characters into the file and interpret them as symbols.

"Not all things that are possible are necessarily a wise thing to do." :)

(*) That also doesn't mean some compiler vendor may not have implemented same as an extension beyond what the Standard mandates as minimum.

Sign in to comment.

Products

0 Answers