Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

examples/push: fix constructor syntax #50

Merged
merged 1 commit into from
Jan 30, 2016
Merged

examples/push: fix constructor syntax #50

merged 1 commit into from
Jan 30, 2016

Conversation

proppy
Copy link
Contributor

@proppy proppy commented Jan 30, 2016

No description provided.

proppy added a commit that referenced this pull request Jan 30, 2016
examples/push: fix constructor syntax
@proppy proppy merged commit 64a5de8 into master Jan 30, 2016
@@ -20,8 +20,8 @@
#include <Firebase.h>

// create firebase client.
Firebase fbase("example.firebaseio.com")
.auth("secret_or_token");
Firebase fbase = Firebase("example.firebaseio.com")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax is odd for c++. You are basically telling the compiler to create a empty Firebase object "fbase" then copy another anonymous Firebase object into it. So two objects + copy constructor. Copy elision should optimize this away but depending on a compiler optimization looks odd to c++ eyes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I just restored the example the way it was before.

I think moving forward we should embrace two-step initialization, which seems to be a common pattern in Arduino-land.

Firebase fbase;

void setup() {
 fbase.begin("host", "auth");
}

WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a little more combersome but I can see how it is useful with the setup() loop() cycle. We could provide both options.

How about we call it "setup()" instead of begin though. to match the arduino function name.

@proppy
Copy link
Contributor Author

proppy commented Feb 1, 2016

How about we call it "setup()" instead of begin though. to match the arduino function name.

Most of Arduino object have a begin():
https://www.arduino.cc/en/Serial/Begin
https://www.arduino.cc/en/Reference/WiFiBegin
https://www.arduino.cc/en/Reference/SPIBegin

That's why I initially suggested this :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants