Jump to page: 1 2
Thread overview
function parameters: is it possible to pass byref ... while being optional at the same time ?
Jul 17, 2021
someone
Jul 17, 2021
Adam Ruppe
Jul 17, 2021
someone
Jul 17, 2021
Jack Applegame
Jul 17, 2021
someone
Jul 18, 2021
zjh
Jul 18, 2021
Brian Tiffin
Jul 18, 2021
Ali Çehreli
Jul 18, 2021
someone
Jul 18, 2021
Ali Çehreli
Jul 18, 2021
Adam D Ruppe
Jul 18, 2021
someone
July 17, 2021

The following gives me a compiler error when I add the second parameter:
is not an lvalue and cannot be modified

public bool add(
   ref classTickerID robjTickerID,
   ref classExchanges robjExchanges = null /// needing this optional
   ) {

}

If I take out the null then the parameter is assumed mandatory of course.

July 17, 2021

On Saturday, 17 July 2021 at 20:49:58 UTC, someone wrote:

>

ref classTickerID robjTickerID

Why are you using ref here at all?

You probably shouldn't be using it. But if it is legitimately needed you can do a pointer instead of ref.

July 17, 2021

On Saturday, 17 July 2021 at 20:49:58 UTC, someone wrote:

>

The following gives me a compiler error when I add the second parameter:
is not an lvalue and cannot be modified

public bool add(
   ref classTickerID robjTickerID,
   ref classExchanges robjExchanges = null /// needing this optional
   ) {

}

If I take out the null then the parameter is assumed mandatory of course.

Just remove ref, because in D clasess themselves are references.

July 17, 2021

On Saturday, 17 July 2021 at 21:02:38 UTC, Adam Ruppe wrote:

>

Why are you using ref here at all?

Muscle memory I suppose; objects need to be passed by reference, these are the things I'll need to be re-wired to in D.

>

You probably shouldn't be using it. But if it is legitimately needed you can do a pointer instead of ref.

No. Nothing special at all here.

July 17, 2021

On Saturday, 17 July 2021 at 21:46:38 UTC, Jack Applegame wrote:

>

Just remove ref, because in D clasess themselves are references.

All refs are goners now; thanks :) !

July 18, 2021

On Saturday, 17 July 2021 at 22:40:35 UTC, someone wrote:

>

On Saturday, 17 July 2021 at 21:46:38 UTC, Jack Applegame wrote:

This must be Forum Oriented Programming.

July 18, 2021

On Sunday, 18 July 2021 at 00:00:01 UTC, zjh wrote:

>

On Saturday, 17 July 2021 at 22:40:35 UTC, someone wrote:

>

On Saturday, 17 July 2021 at 21:46:38 UTC, Jack Applegame wrote:

This must be Forum Oriented Programming.

It's our best hope. Self taught programming is scary. School taught programming is scary. Corporate taught programming is scary. Practice makes perfect? No, practice makes permanent.

The sanest path forward for the profession is Peer taught programming, in public.

July 17, 2021
On 7/17/21 6:49 PM, Brian Tiffin wrote:

> *Practice makes perfect?  No, practice makes permanent.*

One reference for that quote is "Classical Guitar Pedagogy" by Anthony Glise, Chapter Nine--Practicing. ;)

Ali

July 18, 2021

On Sunday, 18 July 2021 at 01:49:11 UTC, Brian Tiffin wrote:

>

It's our best hope. Self taught programming is scary. School taught programming is scary. Corporate taught programming is scary. Practice makes perfect? No, practice makes permanent.

The sanest path forward for the profession is Peer taught programming, in public.

I am a self-taught programmer well before college, furthermore, I am almost a self-taught guy in everything that interests me (albeit the fact that I have a degree in electronics engineering), but I am not, in any way, ashamed to ask anything no matter the issue, I have no pride when I am asking questions, I am not ashamed to answer no when I don't have the answer, I want to learn, and to teach whenever I feel I have and edge on something.

That being said, one of the things that I felt in love with when I was first exposed to was OOP; with all its pros and cons. OOP made me a far better programmer than I was before. And it was not in college nor anywhere near to, it was on one of my first jobs as a developer at a financial institution which by the time back in the early 90s was using a database manager called FoxPro wich evolved to Visual FoxPro by the time Microsoft bought it and it was fully OOP from top to bottom and was far ahead of similar tools of the era, so far ahead in the language and flexibility and speed that a few years after it was released Microsoft killed it because a lot of companies were doing serious business with it while not buying Microsoft's star-database, SQL Server, which obviously was far far expensive.

It was with this tool that I learned primarily to encapsulate everything -and it payed off; code quality using OOP was far superior. These were my humble origins to OOP far away from things like LISP and what-not that I didn't know they even existed. C++ came afterward with all its complexity and 50% of the guys loving it and the other 50% hating it with passion. I don't know of any other language so divisive than C++. And no, I don't love it nor hate it, I respect it, it is powerful, the problem with C++ is that anyone writing code with it feels the need to show you how big has his ... and you came across constructions that seem complex puzzles; so, in practice, unless you have some guidelines cast in stone at company level, you end fighting the language, or more precisely, the ones coding with the language.

July 17, 2021
On 7/17/21 8:52 PM, someone wrote:

> I am a self-taught programmer

Same here.

> well before college

Not here because I had access to a Sinclair Spectrum only in 1985. :/

> I have a degree in electronics engineering

Same here.

> one of the things that I felt in love with when I was first exposed to was OOP; with all its pros and cons

I learned it with C++. Then I realized that it wasn't much used in D. The following two presentations made me leave it completely behind unless a simple class hierarchy is really necessary.

1) Our friend Luís Marques presented the following at one of our local meetups. (He was distant. :) )

  http://files.meetup.com/18234529/luis_marques_anemic_domain_models.pdf

That presentation concludes that anemic domain models are better than rich design models.

An interesting question from the presentation to all OOP people is "How might you design a program that lets people play Monopoly with each other over the internet?"

Very eye opening!

2) Our "open methods" friend Jean-Louis Leroy concludes that OOP took a wrong path in programming language history:

  https://dconf.org/2018/talks/leroy.html

It starts with the "expression problem" (which is *not* about "expressions").

> it was on one of my first jobs as a developer at a financial institution which by the time back in the early 90s was
> using a database manager called FoxPro

Same here! :) I learned and programmed in FoxPro for my first job in the US, in Sausalito, CA in 1994. I was maintaining and improving an order entry, invoicing, inventory, etc. system.

I had not even heard about OOP back then to know whether FoxPro was good at it. :)

> It was with this tool that I learned primarily to encapsulate everything
> -and it payed off; code quality using OOP was far superior.

Ah! OOP carries many meanings with it. Yes, encapsulation is important, which I take less advantage of as I gain experience. :) (I am going backward!) But I left "everything is an object" mantra way back in my programming history. Pffft!

> C++ came afterward with all its complexity and 50% of the guys loving
> it

I've been one of those.

> I respect it, it is powerful, the
> problem with C++ is that anyone writing code with it feels the need to
> show you how big has his ...

That.

I've been there myself and I am pretty sure most of the brain power that is attracted to C++ is there for the same reason. I asked a C++ speaker why he was interested in C++ instead of one of the more modern languages and he said "because it is hard".

> unless you have some guidelines cast in stone at company level

More than 400 rules in Core Guidelines alone... Add to that more hundreds of MISRA, AUTOSAR, etc. standards. How can one expect programmers to observe all of those rules? And only some of the guidelines are machine-checkable.

Anyway... Back to D... :)

Ali


« First   ‹ Prev
1 2