Click here to Skip to main content
15,115,667 members

Comments by honey the codewitch (Top 128 by date)

honey the codewitch 20-Nov-21 5:33am View
   
I'd have suggested they continue to ask the question until their code magically works.
honey the codewitch 15-Nov-21 13:31pm View
   
Why did you take a job you're not qualified to do?
honey the codewitch 10-Nov-21 11:54am View
   
Can you post several example strings, with example matches you'd like to see?

List several variations of this (including one with no matches)

And then below each one, list on a separate line each substring you'd like matched.


AB-0001234/00005-Testing My Regex hereAB-0004567/00007-Second Testing of my regex
--- matches ----
AB-0001234/00005
AB-0004567/00007
Second
Testing

(assuming you also wanted to match Second and Testing - i know you don't, i'm just trying to give you an example)

Anyway, make at least 4 of those, including one with no matches, and I bet you'll have a better time getting an answer.
honey the codewitch 9-Nov-21 22:35pm View
   
Thank you! That clears it up for me perfectly.
honey the codewitch 5-Nov-21 5:02am View
   
That was my original plan for Python. I just wasn't sure if it was valid. Actually right now I think my multiline conditionals are indented once rather than twice but it's an easy fix in my generation template. the big issue is knowing what's valid, and secondarily what's pretty. I'm on the fence about double indenting multiline conditionals hanging off of ifs. It's prettier to corner case it, but I don't like it because it's not consistent with the general rule of indenting I follow through the rest of my code. It just rubs me wrong.
honey the codewitch 5-Nov-21 4:34am View
   
Not in that case, but there are other cases where it's needed. It makes code generation a bear. Fortunately in my current case the blast radius of this problem is limited to if () statements.
honey the codewitch 5-Nov-21 3:08am View
   
Thanks, I totally blew by the link in the reply. It's the hour that it is. I'm not altogether with it right now. =)
honey the codewitch 5-Nov-21 1:29am View
   
Are you sure it's not indented at the next level? My google fu isn't helpful right now, and I don't want to stop what I'm doing to start an install of that mess. Oh well. I'll figure it out one way or another. Thanks.
honey the codewitch 11-Jul-21 11:55am View
   
I can't target C++20 unfortunately. I'm limited by the minigw gcc version used by platformIO under windows (the least up to date build platform) and that means C++14
honey the codewitch 11-Jul-21 11:54am View
   
> Can't you just say that instantiations must include various has_blah functions

In some cases, maybe if I had designed it that way. However, because things are typed to a pixel definition and other things, you can't use bool functions for every case. You have to use usings in some cases. Since I already have a using for this case, I find it inelegant to require the draw target implementer to create function to say essentially the same thing.
honey the codewitch 11-Jul-21 8:28am View
   
I have an idea though. I'm wondering if I can't go template<typename T,size_t NativeBitDepth=T::native_pixel_type::bit_depth> struct test_for_native_pixel_type { ... } or something like that. I don't know what the compiler will do there if native_pixel_type isn't declared. My assumption is that it would error but perhaps it wouldn't. I need to check. It would only be zero if native_pixel_type was not present and the compiler had to choose a default for size_t. It *could* work, i just don't know if it will.
honey the codewitch 11-Jul-21 8:21am View
   
I have "draw destination" classes which are loosely defined (bound via template) and have an interface/contract that includes usings. One of the members might be something called native_pixel_type and if it's present it tells me that "virtualization" is being used which means it's dithering. If it's dithering I don't want to use anti-aliasing to smooth the edges of fonts because there's not a true grayscale to work with, just black and white.
honey the codewitch 25-May-21 11:50am View
   
Whoops, I forgot to increment my fill pointer. Not sure what i was thinking. Still, it doesn't solve my issue but thanks for spotting that.

Edit: Never mind. retr() will fill "fill" each time with new data. The y is just there to make sure it gets called the right number of times.
honey the codewitch 25-May-21 10:57am View
   
The reason it's defined that way is it's 16-bit color values, but send and retr take a byte array. It's fine - casting does nothing to the data. It only changes how the data is perceived. It is a "pure" operation with no side effects (unless it is overloaded, and in this case it isn't). say you had a 16 bit word of 0xC1A2. If you cast that to bytes you'd have a byte C1 followed by A2 (actually reversed on little endian systems but you get the idea). send and retr deal in BLOBs which are byte arrays, effectively. But it's easier to deal with pixels in their native format, hence the discrepancy there. a 16 bit pixel is R:5, G:6, B:5 so you can't split it cleanly.

As to your second question, each color is 2 bytes. The pixels are 320 across. The compiler will "fold" the value to 640 with no runtime overhead, but defining it this way makes it clearer that it's 320 pixels of 2 bytes each. It's just a way to express intent with code.
honey the codewitch 24-May-21 8:59am View
   
If he does, he'll regret it. I didn't post the answer for him. I posted it because it was a good question. I half assumed he'd be kicked for the autism remark.
honey the codewitch 10-Apr-21 7:37am View
   
Thanks. I actually tried that after I posted the question, but I had the syntax wrong. I ended up writing a helper function to disambiguate. It's for the best anyway that I did it that way, in the end. Still, this is the proper solution.
honey the codewitch 2-Apr-21 3:19am View
   
Prototype it in C and then simply spit the asm out using the compiler.

There's hardly any reason to use an assembler directly anymore, and many good reasons not to, but if you *must* use an assembler, use C or C++ to prototype your assembly code where you can.

The above can easily be written in C, so write it in C, and then use your favorite C compiler to get the assembly from it, and then look at that.

You haven't specified which assembly you want. Are you coding for an ATmega2560, a Tensilica, an ARM, x86?

Don't bother. Just use C and get asm that way. If you want to tune it from there you can.
honey the codewitch 17-Mar-21 12:17pm View
   
Okay, it sounds like what you're really trying to do is access something like a control from outside the form it's declared on. For example, you have class a that needs to access an instance of Form.cs. Where is Form created? Because first you'll need that. If it's your main form, it's created in Program.cs in the Main() routine as part of Application.Run().. it calles "new Form()" - you will need the value it returned to access any fields in it. It is simply not otherwise directly possible since that form could be anywhere in memory. Or there might even be more than one of them, or none of them. Without some sort of access to the "pointer" for the instantiated Form you are out of luck. Form is just a class. It's nothing until it's created with "new"
honey the codewitch 3-Mar-21 12:53pm View
   
src/vfs.hpp:152:31: error: invalid conversion from 'int (*)(int, stat*)' to 'const void*' [-fpermissive]
memcpy(&test1,vfs.fstat,sizeof(void*));

I can't set the permissive flag because gcc is run as part of a large, complicated toolchain and it doesn't like to be touched.
honey the codewitch 3-Mar-21 12:38pm View
   
Yeah i caught that a minute ago. it amazes me i let that go. I've updated the code. it still doesn't compile.
honey the codewitch 22-Dec-20 10:03am View
   
I know i know. it's early and i'm sleepy and typos and poorly worded thoughts flow freely from me right now.

Edit: (per yours), Yeah I may need to break out paint!
honey the codewitch 13-Dec-20 11:29am View
   
Normally I don't find much occasion to mix them, but I wanted a more compilery, less preprocessory way of defining a maximum capacity for a fixed length array.

I'm not aware of a better solution to the problem than what I've done above, in this particular instance. The code difficulty is limited because the class isn't that complicated. This was one wrinkle, and it was a compiler SNAFU. A good reason not to use it sure *if a better replacement can be had* but I'm not aware of one for this case.
honey the codewitch 13-Dec-20 10:37am View
   
Totally. They can be frustrating at times, but Accelerated C++ changed my life and I do a lot of generic programming now. Less so on Arduino stuff but still.
honey the codewitch 13-Dec-20 10:32am View
   
nah it should be able to forward precisely *because* it's virtual. there's a vtbl in play so it just needs to find the function.

Turns out the compiler was looking for a global function called initCapture().

Since it's part of a template there's a 2 phase resolution process in C++ and it wasn't picking it up as part of the class.

So if you do this->initCapture() it all works fine. It gives the compiler what it needs to look in the right place (the base class) for the function.
honey the codewitch 11-Dec-20 19:59pm View
   
Wonderful! I'm so glad when my stuff can help someone. We all start somewhere. Good luck with your project!
honey the codewitch 11-Dec-20 9:45am View
   
unique_ptr takes the type and decorates it so you're creating a pointer to a pointer. Solution 1 is the correct answer.
honey the codewitch 1-Dec-20 7:07am View
   
You've said nothing about the problem. You've just mentioned that a problem exists. How is anyone supposed to help you when they don't know the nature of the problem you are running into? "Licensing issues" is not a description of the problem, and most people may not have heard of "black duck scan"
honey the codewitch 30-Nov-20 20:36pm View
   
You can't use windows forms in core 3.0. Either way you're going to need to create a window from the looks of it. It might not need to be visible. That, and the code I offered is what I have. If you want to know about TWAIN you'll just have to study it as I don't know anything about it.
honey the codewitch 29-Nov-20 12:48pm View
   
Hey thanks. This is awesome! You don't mind if I use a derivative of this code in a commercial gadget do you?
honey the codewitch 29-Nov-20 11:47am View
   
Thank you!
honey the codewitch 29-Nov-20 9:23am View
   
I can't do it that way because readNextPoint() reads from flash which is very slow. I need to do it one sample at a time to keep things running smoothly, if I can at all.

Therefore if my solution gets me the same as your solution I prefer my way. I actually endeavored to avoid doing it the way you do.

I should add that the number of points is compile-time configurable depending on the defined resolutions so sometimes that loop might be much larger. =)
honey the codewitch 29-Nov-20 8:30am View
   
I'm going to add to make it explicit. It appears his data and not his query is the real culprit. I'll also explain INNER JOIN here since he was asking. Inner join simply combines columns from two tables where one or more columns in one table correspond to some columns in the other table (either directly or indirectly through a formula)
honey the codewitch 28-Nov-20 7:53am View
   
Beat me to it
honey the codewitch 25-Nov-20 19:34pm View
   
I'll have a crack at this after I've had some sleep but what really jumped out at me was it's spelled "vertical" not "virtical" and I'm having a hard time getting past that.
honey the codewitch 20-Nov-20 6:23am View
   
This should be in the "Demands" section.

You may have heard differently, but this site isn't full of monkeys that will simply do your bidding.

Perhaps study.
honey the codewitch 15-Nov-20 10:34am View
   
ooh that could be fun depending on whats on the other COM ports. :P
honey the codewitch 14-Nov-20 12:47pm View
   
I'll say it again: if you have to rely on undocumented functions to release an object, you are doing it wrong.

The proper way to request that a disposable object dispose itself is IDisposable.Dispose().

Disagree all you want, because it doesn't change the facts on the ground. The framework doesn't care about your disagreement, frankly.
honey the codewitch 14-Nov-20 11:37am View
   
I'm going to don my software architecture hat for a moment to say if you need to use undocumented functions to free objects you've been doing something terribly, terribly wrong in the first place. Take a step back and retrace how you got here, because you made a wrong turn. There are so many reasons not to do what you are trying to do. It's a large flaming anti-pattern.
honey the codewitch 13-Nov-20 11:20am View
   
I know it's kind of not, because Ints can interrupt anywhere, but (maybe not with the ESP32) when an interrupt is called the other code is suspended, which is why i said it's single threaded for the purpose of the code. I may have been making a bad assumption about the value of timestamp, but above is what i meant by consider this single threaded - there's no other code running at the same time, but yes i know it can pull an interrupt anywhere.
honey the codewitch 13-Nov-20 11:17am View
   
That's great to know. I am still brand new to the ESP32, and fairly new to the Arduino and ESP8266 modules as well, but I've at least built several things with the arduino, and ESP8266s so far.
honey the codewitch 13-Nov-20 8:32am View
   
I'm a member of the ESP32 forum on reddit. I looked there first but didn't see anyone posting code, so I figured I'd try here first. Wasn't sure how they'd feel about blowing up their forum with all that source.
honey the codewitch 13-Nov-20 8:26am View
   
Ah yeah I reread it and you're right. Still, the code shouldn't hurt. The 3rd solution was the fix.
honey the codewitch 13-Nov-20 8:25am View
   
BRILLIANT! Thanks so much!
honey the codewitch 13-Nov-20 8:23am View
   
I'm not sure the standard library is available on arduino's devkit but i'll try this. Thanks.
honey the codewitch 13-Nov-20 5:15am View
   
It doesn't assume that, or rather, the assumption is safe, since loop() would simply skip the timeout check on that iteration.

Also, for the sake of this question, consider the code single threaded.
honey the codewitch 13-Nov-20 4:47am View
   
Ummmm, ish? AFAIK all the code seems to be single threaded, and yet the thing is dual core. Also it was said I needed to use volatile on global vars accessed within interrupts like callback which suggests some sort of concurrent access I think. I didn't mark _timestamp with volatile above but i have to no avail.
honey the codewitch 13-Nov-20 4:43am View
   
Read the code and read the comments in the code. millis() doesn't work in that routine

If you see loop() routine

// for callback():
  if (!_timestamp)
    _timestamp = millis();


That indeed resets the timeout. The comment is correct.
honey the codewitch 15-Oct-20 14:22pm View
   
You're creating exactly what I'm talking about. Don't worry about it. =)

I meant the best thing is have all the hacks behind something as "clean" as you can create, but it sounds like you're doing that.
honey the codewitch 15-Oct-20 14:21pm View
   
I should add, EnumWindows() and its derivatives don't give you a stopping condition. They will keep calling you back with windows until there are no more but you won't know when there are no more because it will never tell you. I rig a timeout for it.
honey the codewitch 15-Oct-20 13:59pm View
   
About the best you can hope for is make a facade out of this and expose an API for it so you don't pollute more of your code than absolutely necessary.
honey the codewitch 15-Oct-20 9:49am View
   
I think you should try your next approach. It's what I would have suggested. Keep in mind you're trying to interact on some level with an app that wasn't designed to interact with your app so anything you do is going to be somewhat ugly. Windows has crappy window finding APIs - that's the bottom line. Usually an app will be designed for interaction and they will publish an API into the Running Object Table, obviating the need for window based interaction. Even if they relied on windowing for IPC the server app would publish its window in some way known to the client so the client knew how to get to it later. You don't have luxury. Given all that, you're on the right track.
honey the codewitch 2-Oct-20 15:33pm View
   
Presumably you have a reason you'd like the order preserved but the JSON spec does not guarantee the order of named items - that's what XML is for. Basically what you want is to hack the JSON protocol to meet your requirements. Not that it can't be done, but know that what you want to be doing is a hack.
honey the codewitch 24-Sep-20 13:05pm View
   
I'm not going to remote desktop with you, sorry. I don't have any more time for this right now anyway.
honey the codewitch 24-Sep-20 12:07pm View
   
okay, fair enough. i'm having trouble tracking down where the bottleneck is then.

If calling Reader() from another thread didn't solve it, and if the bottleneck is not that Api() stuff you're doing (which looks a whole lot like a COM port read) then I don't know where your bottleneck is in your code, and since I cannot run the code I cannot find that out.
honey the codewitch 24-Sep-20 10:54am View
   
I found the problem I think. I can't test it though. I think your bottleneck is either your USB or COM port (whichever you are using).

I can keep a form responsive for you, but as you said that doesn't matter. What matters is you need to be able to submit to a database while other card reads are occurring.

Here's your problem - you don't have enough bandwidth. If it's USB, you need more than one bus. If it's a COM port you're going to need a lot more of them if you want to do a lot of concurrent reads.

Going through your code, indeed, firing the Reader() method on a separate thread will keep the form responsive but it will not make the reader hardware more responsive.

Especially if you're using a COM port, there simply isn't enough bandwidth
honey the codewitch 24-Sep-20 5:56am View
   
Yeah, it turns out, it needs an entire rewrite.

Your code isn't usable. So I'm trying to reverse engineer the Api you have for hardware I don't even own. Be patient
honey the codewitch 22-Sep-20 10:53am View
   
And multithreading is not really something you want to be doing after two months.

It's like doing an engine/motor swap on a car right after learning to change the tyres/tires

I'm going to see if i can rig up something for you that avoids it
honey the codewitch 22-Sep-20 10:52am View
   
okay. i'll look at it. here's a temporary email address i'll look for it from

honeythemonster@mail.com
honey the codewitch 22-Sep-20 10:46am View
   
i don't have the hardware to run it. and I can't rewrite everything without it which is the first thing to do.

for code to be multithreaded it has to be well encapsulated. You have no consistent encapsulation from what I've seen. every member is whatever you thought you'd need at the time, and where's the planning?

sit down, plan it, then write it. consider your first attempt a draft.
honey the codewitch 22-Sep-20 10:31am View
   
And that's what you want? Well, since your code is all jacked up anyway, maybe try creating the entire form on its own thread.

ThreadPool.QueueUserWorkItem((state)=>{Application.Run(new myForm());});

Which may or may not work.

Honestly I'd never accept your code if I was reviewing it. So if this is for work? Rewrite it. It could get you fired.
honey the codewitch 21-Sep-20 9:50am View
   
Part of your problem is you're trying to run before you can walk. Multithreading is one of the most difficult programming problems. Your code isn't clean, isn't readable, and isn't properly encapsulated, so you can't build it up without it falling over under its own mess. Trying to make it multithreaded is just going to make anything wrong with it that much worse.

That's why I suggested the rewrite after the first couple of things didn't work.
honey the codewitch 21-Sep-20 9:46am View
   
It could be a limitation of your device. Bandwidth isn't infinite. Or it might be somewhere else in your code, who knows? Frankly your code is a mess, and I can't even make enough sense of it to tell you that what you're doing now is thread safe. That's why I suggested a rewrite in my other reply.
honey the codewitch 21-Sep-20 9:15am View
   
I don't want to be harsh, but that code is very difficult to read, and looks like even if it was "working" it would crash due to a race condition. I just can't make something whole with what I was given.
honey the codewitch 21-Sep-20 8:58am View
   
Yeah, but you're not going to like it: Go back, reread the documentation for the RFID equipment, and then rewrite the code entirely.
honey the codewitch 20-Sep-20 9:57am View
   
adding, I think your app has design problems that are well beyond the scope of this Question and Answer forum.
honey the codewitch 20-Sep-20 9:55am View
   
I think you need to take the timer or loop out of RfReader()
I think you need to move it into your loop

while(true) {
RFReader r = new RFReader();
r.Read(); // you'll have to add this method
r.Close()
}

Like that. I still have no idea what you're doing with the results of it, but I imagine whatever it is it's probably not thread safe anymore
honey the codewitch 20-Sep-20 9:43am View
   
while(true) {
// do work
}

Inside that loop you might try creating the RFReader() and using it, and then destroying it each time.
honey the codewitch 20-Sep-20 9:41am View
   
while(true) {
// do work
}
honey the codewitch 20-Sep-20 5:26am View
   
Let me see if I can untangle this code and figure out where your per instance data needs to be. I might not have a solution for you right away, since it's 2:30am and I need to go to sleep again at some point but I'll try to figure this out based on what you posted.

Edit: Can you use more than one instance of RfReader() at a time? if you can then I may modify the code to create one RfReader() per call and then eliminate the timer call from RfReader() entirely. If you spin a loop in your thread you won't need a timer anyway.
honey the codewitch 20-Sep-20 5:11am View
   
It looks like you're going to have to modify your code extensively then because your reader routine uses member fields from the looks of it. That means one reader per form which is not what you want. You should be putting those members you are using in a class, and using one class instance per reader call. Something like that anyway. I can't see enough of your code to be sure exactly what you're doing there but basically, you have a design issue from the looks of it. Your member variables are one per form, and i think you need them to be one per reader.
honey the codewitch 20-Sep-20 5:10am View
   
It is familiar, but it's also a pain to demonstrate the use of it in this format because there's just a lot to hooking it up. And every method I gave him spawns a background thread. Either way, it looks like his issue is a design one since he is using member variables in Reader() and wants multiple instances of those variables (1 per reader instead of 1 per form)
honey the codewitch 20-Sep-20 4:57am View
   
Deleted
It looks like you're going to have to modify your code extensively then because your reader routine uses member fields from the looks of it. That means one reader per form which is not what you want. You should be putting those members you are using in a class, and using one class per reader call. Something like that anyway. I can't see enough of your code to be sure.
honey the codewitch 20-Sep-20 4:45am View
   
I mentioned it, but it's actually more code to use it, which is one of the reasons I don't like it. More code = more potential for bugs, and frankly, BackgroundWorker kind of obscures things a little too much for my taste. Just my $0.02 but I don't think the class should even exist.
honey the codewitch 5-Aug-20 11:26am View
   
Richard, I agree with you and I'm guessing his prof is feeding him .NET 1isms. And it doesn't surprise me that it's javalike naming if it's coming out of a school. Seems like all those cats deal in is java, even if they're mucking about in a different language.
honey the codewitch 4-Aug-20 11:31am View
   
If you are writing web server code keep everything synchronous! ASP.NET is not designed for async. The page lifecycle runs beginning to end, so all processing must be done sequentially for the page to render anyway. All you'd be doing is messing up ASP.NET's thread pool heuristics since it's not designed for this. Better to not use Task at all. Hope this helps!
honey the codewitch 4-Aug-20 11:15am View
   
Thanks folks =)
honey the codewitch 3-Aug-20 15:40pm View
   
You should use a ManualResetEvent object to trigger when the thread is done. do a different one for each thread. When you need to wait call WaitHandle.WaitAll() and pass it all if your ManualResetEvent objects. You set one of those with Set(). If you do WaitAll() it will wait until they are all set.
honey the codewitch 3-Aug-20 15:13pm View
   
I won't post this as an answer, because it's not, but you'd have a much easier time I think using Tasks instead of threads. Then you can just await them
honey the codewitch 7-Feb-20 13:41pm View
   
Thanks so much. I figured out what it was doing, I think, and converted it to a struct which *should* work. *knock on wood*
honey the codewitch 9-Sep-19 15:13pm View
   
hey, I added some stuff to make it easier to use. Quick Demo in "scratch"

You can now take the reader and do like reader.SkipTo("field1","field2",0 /*array index */,"field3");

like that

Quick and dirty Demo is in "scratch" at my github

https://github.com/codewitch-honey-crisis/Json

Hope that helps. Remember that skip to field lands you on the FIELD not the Field's value, so you have to call Read() one more time if you land on NodeType of Key

Call ParseSubtree() once you're positioned on the subtree you want to parse into objects. You can then use JSON path on that.

https://github.com/codewitch-honey-crisis/Json

Here's the source link

hope that helps!
honey the codewitch 8-Sep-19 12:43pm View
   
That only accepts a flat field name. If it can't find it it returns null. It's literally looking for a field with slashes in it in your query (and that's doable in JSON) Instead you have to do like:

reader.SkipToField("foo");
reader.Read(); // i think you need this. maybe not. comment out if need be
reader.SkipToField("bar");

to navigate to "foo/bar"

I don't support JSON path in the queries, nor "xpath" here because i didn't write the JSON path part and it only works on the trees you get back from ParseSubtree()

adding, if it was supported it would be JSON Path syntax is more like "$.foo.bar"
honey the codewitch 6-Sep-19 2:07am View
   
Not so easily, it's a lot of code. The whole point of this exercise is to avoid having to write it.

If you don't get what I'm asking, that's totally cool. I found another solution anyway that sidesteps this whole issue.
honey the codewitch 5-Sep-19 4:42am View
   
Unfortunately I can't lock the source classes because they aren't mine.

In order to do so I'd have to make wrappers for every single item.

Basically I want .NET to do it for me, except .NET uses a different technique to accomplish the same (it uses a form of message pumping/signalling to synchronize calls)
honey the codewitch 2-Sep-19 23:38pm View
   
things like concurrentdictionary are not what i want. I'm not looking to use synchronized dictionaries. I'm looking to martial calls and sink them on a particular thread, hopefully with .NET doing the marshalling for me like it does with ISychronizeInvoke
honey the codewitch 30-Jul-19 1:19am View
   
thanks! and just what I was hoping for.
honey the codewitch 25-Jul-19 10:25am View
   
One of these days, I should install VB =D
honey the codewitch 25-Jul-19 10:20am View
   
I think that's one bounded, like VB's default. I'll have to check.
honey the codewitch 25-Jul-19 10:09am View
   
what's the proper syntax for declaring this (zero bounded of course) in VB?

if you know.
honey the codewitch 25-Jul-19 9:58am View
   
you have some serious google fu. I'm rusty I guess. Frankly, I wanted to declare this DFA table as a simple nested int array like my parse tables but despite a DFA (the structure i'm serializing above) being conceptually simpler than a PDA (the ints i'm serializing) mathematically, the data structures for them are more complex than such a nested array solution would allow for.

I've half a mind to declare a DfaEntry struct and be done with it.

Frankly I don't even know the proper syntax for that in VB so I can't really blame the VBCodeProvider LOL
honey the codewitch 25-Jul-19 9:39am View
   
i'll update my question. Thanks. I tried not using the initializers, and just setting it to [0] in CodeDom but it didn't change anything. I may have to special case for VB and insert a CodeSnippet object to do this =(

thanks for your help. I'm fresh out of coffee and have been slow this morning. heh.
honey the codewitch 25-Jul-19 9:26am View
   
whoops. sorry, never used the site before. i thought it just edited in place.

here you go: Demo
honey the codewitch 25-Jul-19 9:24am View
   
Deleted
I repro'd it. Check the demo at your link. and thanks again
honey the codewitch 25-Jul-19 9:23am View
   
Richard I repro'd it. Check your Demo link
honey the codewitch 25-Jul-19 9:15am View
   
Thanks Richard. I guess I didn't repo it right because the same code breaks on my machine.

I'd give you the actual data I'm serializing to the codedom but it's pages long.
honey the codewitch 24-Jul-19 15:19pm View
   
i mean sure. but now how to get the codedom to render that properly.
honey the codewitch 23-Jul-19 17:11pm View
   
well yeah i think it is a value type in that it derives from ValueType instead of directly from object, but that's not really what i'm looking for as int also returns true there too.

you can't declare partial generics but you can call typeof on them so like typeof(IList<>) works but class foo : IList<> {} does not

i think the ValueTuple just uses ref internally (is a ref type) or something like that. i'd have to check
honey the codewitch 23-Jul-19 12:54pm View
   
That's what I figured but Richard Demming below found the magic I was looking for. Requires .NET 4.71 but that's fine.
honey the codewitch 23-Jul-19 12:52pm View
   
There's the magic I was hoping for! re: ITuple
honey the codewitch 23-Jul-19 12:32pm View
   
i'm pretty sure i tried that and it didn't work for me. My tuples i'm using as a test set have two arguments. That might have something to do with it. I also tried typeof(Tuple<>) on a lark. I can't do typeof(Tuple<,>) because i don't know how many arguments the tuples will have in advance. I'll try Tuple again just to be sure and amend my response if i'm wrong
honey the codewitch 23-Jul-19 12:31pm View
   
whoops my mistake. I had my mind on other things. I've kind of retired the question as I stopped using tuples here but I'd still like to know a solution
honey the codewitch 12-Jun-19 8:21am View
   
can you give us a C/C++ header for the struct you are importing?

I need to see the native types to get you a proper p/invoke

it may need to marshal stringbuilders or fixed length strings inside the struct or something. it could be anything. i need to see the native header for the struct
honey the codewitch 5-Jun-19 9:35am View
   
thanks
honey the codewitch 10-May-19 11:51am View
   
Aaand I solved it. Sure enough, an inner loop was required (could have been done recursively)

It's kind of involved. Your solution didn't quite do it, but it almost worked. I am using a variation of the concept in it anyway
honey the codewitch 10-May-19 11:39am View
   
I don't think I'm explaining myself well. I mean recursive in the same way a sort() method might be. recursive comparisons, not comparisons over a recursive data structure, if that makes sense.

adding, it's possible to make those things recursive.

expr -> term expr

honey the codewitch 10-May-19 10:34am View
   
yeah I'm using a dictionary in my code, but thanks for the heads up anyway. I'm basically adapting what you solved to see if it works. It looks too simple. I'm almost positive the solution will be recursive or at least use nested loops, but maybe I'm wrong. If you're interested, this is part of a larger problem called left factoring LL grammars

https://www.tutorialspoint.com/compiler_design/left_factoring.asp

honey the codewitch 10-May-19 9:28am View
   
you might have something there but i have to wrap my head around it. MOAR coffee. =) Thanks.
honey the codewitch 10-May-19 9:08am View
   
but how do I know what the prefix is without other items to compare it to?

like in

expr -> ambig2 ambig3

is the prefix expr->ambig2 or expr-> ambig2 ambig3

the trouble is I only know the prefix when compared to other items.
honey the codewitch 10-May-19 8:49am View
   
you can consider them strings for the purpose of the question.

but they are arrays of System.Object - where the object is usually a string. Consider the objects to be comparable with equals

Consider the Left of a -> to be the first element, if that helps

The problem is independent of whether they are arrays or strings, the algorithm will be the same either way.
honey the codewitch 27-Apr-19 1:02am View
   
It used to be de rigueur to do as much validation as realistic in each of the tiers of a multi-tiered app. For the same reason you'd sanitize db inputs on a webpage, but also to protect against attacks if they manage to secure a user level connection to the DB directly.

But that was years ago. 3 tier is old school these days.

Basically though, you'd have the web page provide first tier validation, the middleware perform 2nd tier validation, and where possible, do validation in the DB stored procs.

that way no matter what, your data is hardened against being poisoned by external actors no matter what tier they are operating at.
honey the codewitch 1-Apr-19 14:47pm View
   
whoops, i need more coffee. Still that should be easy enough to port to javascript.

just using string concatenation instead of stringbuilder
honey the codewitch 20-Mar-19 4:19am View
   
Thanks. The last time I tried using ILMerge for this it wound up breaking for some builds and never could figure out why. That was years ago when it was still posted over at MSR or someplace and experimental. I forgot about it until you just mentioned it.

I'll certainly revisit that again.

I want to avoid embedding references as resources (something I've considered) because of the additional concerns it raises in terms of .NET security restrictions and non-fixed disk space requirements - usually doesn't matter but when it does it breaks bad.

I'm going to hold off accepting just to see what other ideas people have, if any.

Your answer regarding ILMerge is potentially a good solution, but I need to look into it.
honey the codewitch 19-Jan-18 13:22pm View
   
part of the reason i'm asking the question is to determine how useful it would be to release the generation tools i built and use to work around this. they're terribly unpolished and work for my narrow scenarios. but they help me get around this issue.

the other reason i'm asking the question is I don't like to use the generated code for that in certain areas of my source, so I've developed some patterns to work around using foreach/yield everwhere, but the patterns look "stupid" unless you know why I do it. they look like anti-patterns. I don't like code that looks like anti-patterns. I get suspicious - even of my own code. =) I also tend to assume I am kinda stupid compared to the people that designed the language. it keeps me humble enough to make assumptions in the right order, to wit, first assume error or ignorance on my part since it's most likely.
honey the codewitch 19-Jan-18 12:59pm View
   
i don't think the VM is the problem.

it's more just the way iterator/yield and linq work.

stuff performs fine when i hand roll it.

honey the codewitch 19-Jan-18 12:58pm View
   
that's what I assumed.

the question was in service to checking that assumption.

i prefer asking questions before deciding on a conclusion.
honey the codewitch 19-Jan-18 12:51pm View
   
you were arguing with Wes Dyer's conclusions, not mine. That's why I said argue it with him.
honey the codewitch 19-Jan-18 12:50pm View
   
not without rewriting pretty much all of linq AND doing code gen on all iterators instead of relying on yield.

i've considered it.
honey the codewitch 19-Jan-18 12:48pm View
   
if i was writing business logic or something they'd probably be fine, even on the server end.

but what i'm doing falls closer into compiler/parsing tools and learning systems (together) - which unfortunately, tend to nest a lot more, and tend to require a bit more "real time" responsiveness compared to displaying a web search or something.

(different types of performance basically, because of different problem domains)

and while my code isn't doing something like DSP/Digital Signal Processing where truly fast streaming would be necessary, it's basically somewhere between that and the larger, chunkier performance issues in dealing with most applications, especially biz-data based applications like many web apps, which is what a lot of .NETs features are geared for.
honey the codewitch 19-Jan-18 12:47pm View
   
Deleted
if i was writing business logic or something they'd probably be fine, even on the server end.

but what i'm doing falls closer into compiler/parsing tools and learning systems (together) - which unfortunately, tend to nest a lot more, and tend to require a bit more "real time" responsiveness compared to displaying a web search or something.

(different types of performance basically, because of different problem domains)

and while my code isn't doing something like DSP/Digital Signal Processing where truly fast streaming would be necessary, it's basically somewhere between that and the larger, chunkier performance issues in dealing with most applications, especially biz-data based applications like many web apps, which is what a lot of .NETs features are geared for.
honey the codewitch 19-Jan-18 12:42pm View
   
helpful! thank you
honey the codewitch 19-Jan-18 12:41pm View
   
i don't use LINQ precisely because of this.

> Right now I hand roll a lot of enumeration stuff, because LINQ performance is unacceptable for extensive use in things like GLR parsers, and part of it is this limitation of yield.

But it's just a lot of work *not* to use it.

Which is why it's looking more and more appealing for me to move away from C# and back to unmanaged code.

meh

honey the codewitch 19-Jan-18 12:36pm View
   
which is what I do. currently.

and it's a side-effect of programming things that rely heavily on set based operations, like most parser generators, just for example.

and yeah, whether it's LALR(1), LL(x) or even FAs there's going to be a lot of iteration and set functions.

nature of the beast.

typically, i'd be using STL in C++ to do things like this.

but for reasons that are outside the scope of this, I've been moving a lot of research code to C#. That includes compiler/parser stuff.

Like I said, if you don't have an answer, that's okay.

I honestly didn't expect anyone to have one.

But it's a good idea to check expectations, especially give i don't usually muck about with the newer C# language features.

hence why i asked the question.
honey the codewitch 19-Jan-18 12:28pm View
   
like is typical with lots of LINQ queries, similarly my code nests these operations deeply.

so yes, it's an issue.

oh, and depending on the collection, we're dealing with things like LR rules so 1500 isn't even uncommon

honey the codewitch 19-Jan-18 12:25pm View
   
fine, it's called concat.

the point still stands. because Union isn't the point. perf is the point.

rename it concat if it helps you answer the question i was asking.

and if you don't have an answer that's fine.
honey the codewitch 19-Jan-18 11:58am View
   
also the reason for the overhead is that those two inner iterators - also yields, could have been rolled into this class. instead you have 3 classes each running their own state machines. it leads to spikes in the perf graph as Wes Dyer already shows at the link.

unless you want to call his perf graphs a lie
honey the codewitch 19-Jan-18 11:55am View
   
you're more than welcome to argue with guy who on the C# dev team that wrote the article I linked to.

but i don't see the need to reargue it.
honey the codewitch 19-Jan-18 11:00am View
   
I don't care about bit twiddling overhead.

Look at the article in the link. This isn't about a little bit of overhead.

It's about time complexity of O(m+n) where m is the number of items in the first sequence and n is the number of items in the second sequence. And it gets worse as you nest, the outermost call is O(m+1). The next call has O((m-1)+1), then O((m-2)+1), ... O(1+1). There are m of these calls so the running time should be O(m^2). Essentially, composing concats together like this causes O(m^2) yield returns to be executed.

(from the article, with performance graphs)
honey the codewitch 17-Jan-18 22:27pm View
   
have iterators changed that much in 9 years?
honey the codewitch 17-Jan-18 22:25pm View
   
this isn't about blaming anything.

it's about not writing enumerator classes by hand anymore if there's a better way to avoid it.

consider me a nihilist when it comes to frameworks and blame.

i don't care who is at fault. i'm just looking for a way to keep using C# even as i basically have to hand-roll a significant subset of what linq and yield provides from scratch an awful lot more than I'd like to.