Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #2102 (closed enhancement: invalid)

Opened 12 years ago

Last modified 12 years ago

Make FindFruct/SearchFruct public

Reported by: nablaoperator Assigned to: community
Priority: minor Milestone: 1.0
Component: Tango Version: 0.99.9 Kai
Keywords: Cc:

Description

Currently FindFruct? and SearchFruct? in tango.text.Search are private. To declare a SearchFruct? instance as a class variable, one has to derive the SearchFruct? type from the search() return type:

import tango.text.Search;

class MySearch ( T )
{
  private const typeof (.search!(T)()) sf;
  
  this (T[] match)
  {
    this.sf = .search(match);
  }

  // Methods follow that search for the string provided in the constructor.
}

Declaring a SearchFruct? instance is apparently not intended, but I want to look up the same match string in many input strings without making SearchFruct? repeatedly rebuilding the same table of offsets. To do so, I don't see a better way than declaring a SearchFruct? class member that is initialized once in the constructor.

Working around the private attribute is a hack and this usage example doesn't look very exotic to me, so would there be a problem in just declaring FindFruct/SearchFruct? public?

Change History

(follow-up: ↓ 2 ) 01/17/12 21:46:39 changed by kris

Those are not intended to be made public, but perhaps I misunderstand the issue ~ you currently can use a single instance to do lookups on multiple input strings ... that's what the content parameter represents in the API.

Or, do you mean to do lookups in parallel across multiple threads? If so, I'd suggest adding a public .dup() method to these classes instead?

(in reply to: ↑ 1 ) 01/20/12 12:39:38 changed by nablaoperator

My point is that I want do keep the SearchFruct?!(T) instance returned by search!(T)() as a class variable, MySearch?(T).sf in the example. To declare MySearch?!(T).sf, I need the type, which is SearchFruct?!(T). So keeping SearchFruct? private prevents me from declaring MySearch?(T).sf unless I do the cumbersome workaround of deriving SearchFruct?!(T) from the return value of search!(T)().

03/20/12 12:40:21 changed by Marenz

  • status changed from new to closed.
  • resolution set to invalid.