Click here to Skip to main content
14,421,680 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: Ccc - you win! Pin
OriginalGriff9-Dec-19 2:23
communityengineerOriginalGriff9-Dec-19 2:23 
GeneralRe: Ccc - you win! Pin
Pompey 39-Dec-19 3:25
MemberPompey 39-Dec-19 3:25 
JokeRe: Ccc - you win! Pin
Daniel Pfeffer9-Dec-19 3:40
professionalDaniel Pfeffer9-Dec-19 3:40 
GeneralRe: Ccc - you win! Pin
Sander Rossel9-Dec-19 3:51
professionalSander Rossel9-Dec-19 3:51 
GeneralRe: Ccc - you win! Pin
Member 798912210-Dec-19 7:27
MemberMember 798912210-Dec-19 7:27 
GeneralRe: Ccc - you win! Pin
Sander Rossel11-Dec-19 3:03
professionalSander Rossel11-Dec-19 3:03 
GeneralRe: Ccc - you win! Pin
musefan9-Dec-19 3:55
Membermusefan9-Dec-19 3:55 
GeneralI never knew I'd miss an operator I hate so much Pin
honey the codewitch8-Dec-19 20:57
mvahoney the codewitch8-Dec-19 20:57 
So C# has "as" which is like an attempted cast. If the cast fails no error is thrown, but the target value is set to null, such like:
string str = obj as string;


A) It's faster than a cast
B) it lets you do two things in one - cast an object and check the object's type.

So it's more efficient than a cast, in .NET

However, it leads to code patterns like

var cc = obj as CodeComment;
if (null != cc)
{
	_VisitComment(cc,args, action);
	return;
}
var ccu = obj as CodeCompileUnit;
if (null != ccu)
{
	_VisitCompileUnit(ccu,args, action);
	return;
}
var cd = obj as CodeDirective;
if (null != ccu)
{
	_VisitDirective(cd, args, action);
	return;
}


C#8? introduced a switch style pattern for this but it's still ugly.

That's why I don't like it.

However,in Slang it is not supported, nor can it be, because the only way to emulate that particular operator (which resolves to a specific IL instruction) is using minor reflection (Type.IsAssignableFrom()), which is unacceptable here.

And so a lot of my code simply won't parse. Dead | X|

Curse the CodeDOM for being so sparse. I really wish it supported more operators. There are no unary operators, no try-cast (like above) and most of the assign operators are gone as are maybe half the binary expressions available in most languages. It's kind of a bad joke but there's nothing to be done about it now. Microsoft made the standard. Others adhere to it, broken as it is.

I mean, the CodeDOM is useful but it's bloody limited. I wish Roslyn had pluggable support for additional compilers like F# but as far as I know it's strictly C# and VB

Still, it might be useful eventually to make a Roslyn version of slang once it too can run on a phone. But for now I'm stuck with the stodgy old CodeDOM. Though working with Roslyn would mean most of what my code does wouldn't be necessary in the first place.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

GeneralRe: I never knew I'd miss an operator I hate so much Pin
OriginalGriff8-Dec-19 21:33
communityengineerOriginalGriff8-Dec-19 21:33 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
Super Lloyd9-Dec-19 0:30
MemberSuper Lloyd9-Dec-19 0:30 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
honey the codewitch9-Dec-19 0:32
mvahoney the codewitch9-Dec-19 0:32 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
OriginalGriff9-Dec-19 0:56
communityengineerOriginalGriff9-Dec-19 0:56 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
harold aptroot9-Dec-19 1:42
Memberharold aptroot9-Dec-19 1:42 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
honey the codewitch9-Dec-19 3:51
mvahoney the codewitch9-Dec-19 3:51 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
PIEBALDconsult9-Dec-19 9:26
professionalPIEBALDconsult9-Dec-19 9:26 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
OriginalGriff9-Dec-19 10:16
communityengineerOriginalGriff9-Dec-19 10:16 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
PIEBALDconsult9-Dec-19 10:49
professionalPIEBALDconsult9-Dec-19 10:49 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
OriginalGriff9-Dec-19 22:14
communityengineerOriginalGriff9-Dec-19 22:14 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
PIEBALDconsult10-Dec-19 4:11
professionalPIEBALDconsult10-Dec-19 4:11 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
Super Lloyd9-Dec-19 0:29
MemberSuper Lloyd9-Dec-19 0:29 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
honey the codewitch9-Dec-19 0:30
mvahoney the codewitch9-Dec-19 0:30 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
Greg Utas9-Dec-19 2:11
professionalGreg Utas9-Dec-19 2:11 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
honey the codewitch9-Dec-19 3:54
mvahoney the codewitch9-Dec-19 3:54 
GeneralRe: I never knew I'd miss an operator I hate so much Pin
PIEBALDconsult9-Dec-19 9:10
professionalPIEBALDconsult9-Dec-19 9:10 
GeneralYAY! Slang parsed 8000+ lines of C# code. Pin
honey the codewitch8-Dec-19 17:29
mvahoney the codewitch8-Dec-19 17:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.