ros / genmsg

Standalone Python library for generating ROS message and service data structures for various languages
http://wiki.ros.org/genmsg
29 stars 74 forks source link

Is constant name must be CAPTITAL letter? #58

Closed k-okada closed 9 years ago

k-okada commented 9 years ago

Hi,

I'm not sure if this is right place to ask question. I think it is convention to use CAPITIAL letter for constant name, but does it MUST be a capital letter?

I see following code in roslisp (/share/common-lisp/ros/actionlib_msgs/msg/GoalStatus.lisp) and I'm afraid it can not distinguish "PENDING" and "Pending"

(cl:defmethod roslisp-msg-protocol:symbol-codes ((msg-type (cl:eql '<GoalStatus>)))
    "Constants for message type '<GoalStatus>"
  '((:PENDING . 0)
    (:ACTIVE . 1)
    (:PREEMPTED . 2)
    (:SUCCEEDED . 3)
    (:ABORTED . 4)
    (:REJECTED . 5)
    (:PREEMPTING . 6)

http://wiki.ros.org/msg

dirk-thomas commented 9 years ago

The snippet seems to only contain PENDING but not Pending so I don't understand what you can't distinguish?

Capital letters are used since that maps well to the code style in various languages. A camel case constant could potentially collide with a class name - a lower case constant could collide with namespace, field name, variable, etc.

dirk-thomas commented 9 years ago

I will close this ticket due to no response. Please feel free to comment with more information.

k-okada commented 9 years ago

Oh, Lisp can not distinguish ':Pending' and ':PENDING'. So I just want to know if using both "Pending" and "PENDING" in constant value in ros message is permitted or not.

[1]> (eq :Pending :PENDING)
T
[2]> (eq :Pending :pending)
T
[3]> (eq :pending :notpending)
NIL
dirk-thomas commented 9 years ago

As I wrote above the convention is upper case for constants. A convention is only a recommendation but diverging from it should only be done for very good reason. Why do you want to diverge from that in the first place?