Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6049455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:34:44+00:00 2026-05-23T07:34:44+00:00

I am trying to understand a point, i know that in this case it

  • 0

I am trying to understand a point, i know that in this case it might be negligible.

When i call, lets say:

float w = object.frame.size.width;

Does the program “calculates” that each time I call it, or does it stores this data on object creation.

I mean what is the difference (in memory usage) between :

float w = object.frame.size.width;
float g = object.frame.size.width;
float s = object.frame.size.width;

And :

float newVar = object.frame.size.width;
float w = newVar;
float g = newVar;
float s = newVar;

Thanks

Shani

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:34:45+00:00Added an answer on May 23, 2026 at 7:34 am

    object.frame.size.width might (and in this case, does) only read and return some c struct property, but bear in mind these can be real objective-c method calls, such as object.color.

    Let’s use another example where it’s not so obvious. You can call object.description on every object to get a string description of that object. That’s clearly the same as the method call [object description]. Do you know what all has to be done to get the description? It’s up to the implementor of that method, but there’s nothing stopping them from doing something expensive, desructive, or otherwise stupid.

    object.doSomethingVeryComplicated will work. It’s not how you’re supposed to use dot notation, and you should never do something very complicated in your getters and setters, and they should never do anything to your object (except lazily initializing it), but there are no hard barriers in place to prevent you from doing this kind of stuff. It’s “only” convention. You could even, theoretically, do object.tellMeYourColorAndThenGiveYourselfANewRandomColor. Now there would obviously be three different answers for your first, and only one answer for your second example.

    It’s up to the implementor of getter and setter methods (which are the only methods supposed to be called via dot notation) to ensure this kind of frivolity does not happen, but there’s nothing stopping the caller of a method to call destrucitve methods that weren’t intended to be used that way via dot notation. Dot notation is a tool for you, the writer, to indicate simple get/set actions to readers of your code (including yourself).

    So, I don’t think the compiler can optimize/abstract example one into example two. But I’m not sure, maybe it really does analyze code so deeple that it knows when this is possible, and when it isn’t. Or maybe it’s possible when it really is only an access to a c struct, as in your example, but not when it’s a real method call. In any case, do you always know which one it is, and what the implications are? I’d go for clarity in my code instead of brevity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to understand how Ruby blocks work, and to do that I've
I was trying to understand something with pointers, so I wrote this code: #include
I'm trying to understand how floating point numbers work. I think I'd like to
Trying to understand an fft (Fast Fourier Transform) routine I'm using (stealing)(recycling) Input is
After trying to understand why client code is not rendered in a page (injected
I've been trying to understand Process.MainWindowHandle . According to MSDN; The main window is
I'm trying to understand someone else's Perl code without knowing much Perl myself. I
I am trying to understand some assembly. The assembly as follows, I am interested
I'm trying to understand the concepts behind DDD, but I find it hard to
I'm trying to understand a particular Perl code from vcake . Usually I find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.