• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Apr 22, 2019 at 11:50 AM by GeoffreyFreudenberg for the following reason:

The question is answered, right answer was accepted

avatar image
1
Question by GeoffreyFreudenberg · Apr 22, 2019 at 02:00 AM · garbage-collectiongcgarbage collectionkeywords

Is it possible to change the definition of '~' from that of a destructor/finalizer and into that of an underscore '_' ?

Hey all. Just kind of a silly question here. I want to use ~ to demarcate my variables, nothing super important, but I did some reading and saw that it's used as a finalizer/deconstructor for garbage collection. It sounds like something I would most likely never use, so I was wondering if it was possible to override the definition of the tilde symbol and change it to be the equivalent of an underscore, so I can put it in front of variables. Is this impossible, or a very bad idea?

Thanks to anyone who can help, or just telling me what a stupid idea it is, haha

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by DiegoSLTS · Apr 22, 2019 at 03:02 AM

That's no possible, you can't replace symbols. I don't know if it's a "bad" idea, but it is really weird trying to modify basic syntax of a language.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Apr 22, 2019 at 03:48 AM 0
Share

Right, in addition to the destructor it's also the unary bitwise not / complement operator. So no, it's definitely not possible. I just wonder for what kind of "demarcating" one would use the ~ character ins$$anonymous$$d of _. They actually look quite similar and can easily be mistaken. So it would counteract the actual goal. What kind of variables do you want to demarcate ? Just give them meaningful names. The only things you may want to distinguish are private vs public variables. I generally use the "old" m_VarName style for private member variables. $$anonymous$$ethod arguments I almost always prefix with an "a" (for argument).

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

106 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Firebase garbage collection bug, trigger GC manually ? ,Firebase garbage collection bug, trigger GC manually 0 Answers

Is generational garbage collection enabled in Unity 5.5? 1 Answer

how does houses in the nature deal with garbage and other kinds of waste 1 Answer

Questions About Allocations - Arrays - Structs and so on 1 Answer

Windows GC problems... 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges